Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve static typing and docstrings related to git object types#1859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 82 commits intogitpython-developers:mainfromEliahKagan:doc-types
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
82 commits
Select commitHold shift + click to select a range
f83b056
Revise assert_never
EliahKaganMar 2, 2024
01cc8e2
Fix unnecessarily long reference in Tree docstrings
EliahKaganMar 3, 2024
6f3a20f
Change how tree[subscript] is introduced
EliahKaganMar 3, 2024
85889cd
Refine how tree[subscript] is introduced
EliahKaganMar 3, 2024
9e47083
Start adding docstrings to types in git.types
EliahKaganMar 3, 2024
3bd8177
Document Tree_ish, Commit_ish, and related types
EliahKaganMar 3, 2024
f3b9a69
Expand docs of classes representing Git objects
EliahKaganMar 3, 2024
2af7640
Do a bit of tidying related to unused names
EliahKaganMar 3, 2024
2aa053e
Add docstrings to TypedDicts in git.types
EliahKaganMar 3, 2024
15d50de
Revise a couple new docstrings for clarity
EliahKaganMar 4, 2024
7166703
Fix possible inaccuracy in Lit_config_levels docstring
EliahKaganMar 4, 2024
1530fd2
Use phrases like "git object type" where applicable
EliahKaganMar 4, 2024
2e02b09
Add docstrings to protocols in git.types
EliahKaganMar 4, 2024
012d710
Move our PathLike below even TYPE_CHECKING imports
EliahKaganMar 4, 2024
a06f1fc
Remove commented-out is_config_level function
EliahKaganMar 4, 2024
c93e431
Expand git.compat docstring
EliahKaganMar 4, 2024
29443ce
Add a cationary note about Object vs. object
EliahKaganMar 4, 2024
b6e3ad2
Don't bind unused _assertion_msg_format
EliahKaganMar 4, 2024
b5d9198
Remove commented-out code
EliahKaganMar 6, 2024
2212ac9
Fix Sphinx reference that rendered overly long
EliahKaganMar 7, 2024
3c5ca52
Simplify _safer_popen_windows "if shell" logic
EliahKaganMar 7, 2024
43b7f8a
Annotate safer_popen broad enough for all platforms
EliahKaganMar 7, 2024
dc95a76
Fix mypy error with creationflags in subprocess module
EliahKaganMar 7, 2024
4191f7d
Refactor kill_after_timeout logic so mypy can check it
EliahKaganMar 7, 2024
1ef3365
Factor communicate and watchdog logic to helper
EliahKaganMar 7, 2024
4083dd8
Fix new mypy confusion about kill_after_timeout type
EliahKaganMar 7, 2024
3aeef46
Fix how Diffable annotates expected repo attribute
EliahKaganMar 7, 2024
f1cc1fe
Fix how HEAD annotates inherited commit property
EliahKaganMar 8, 2024
e133018
Broaden cygpath parameter annotation
EliahKaganMar 8, 2024
c34a466
Have Repo.__init__ convert epath to str first instead
EliahKaganMar 8, 2024
4dfd480
Fix how Remote annotates dynamic config-backed url attribute
EliahKaganMar 8, 2024
e4fd2e3
Drop wrong variable annotations in BlobFilter.__call__
EliahKaganMar 8, 2024
94344b4
Clarify CallableProgress vs. CallableRemoteProgress
EliahKaganMar 8, 2024
8e8b87a
Fix RootModule.update `ignore[override]` suppression
EliahKaganMar 8, 2024
1cdec7a
Fix wrong class name in git.objects.tag docstring
EliahKaganMar 8, 2024
ed6ead9
Correct and clarify Diffable.diff docstring
EliahKaganMar 8, 2024
0e1df29
Start fixing diff and _process_diff_args type annotations
EliahKaganMar 9, 2024
62c0823
Consolidate str and os.PathLike[str] (use GitPython's PathLike)
EliahKaganMar 9, 2024
7204cc1
Further clarify Diffable.diff docstring
EliahKaganMar 9, 2024
2f5e258
Annotate _process_diff_args without Diffable.Index
EliahKaganMar 9, 2024
65863a2
Make NULL_TREE and Index precisely annotatable
EliahKaganMar 9, 2024
c9952e1
Fix Sphinx references; give Diffable.Index a docstring
EliahKaganMar 9, 2024
b8a25df
Modify annotations to accommodate NULL_TREE
EliahKaganMar 9, 2024
e49327d
Add refresh to top-level __all__
EliahKaganFeb 24, 2024
c8ad3a3
Deprecate public access to typing imports in git
EliahKaganFeb 24, 2024
3c8cbe9
Mention collections.abc for Sequence
EliahKaganMar 5, 2024
87b314e
Add INDEX and DiffConstants to git.__all__
EliahKaganMar 9, 2024
9ed904c
Adjust mypy options to work well with mypy 1.9.0
EliahKaganMar 9, 2024
aeacb00
Colorize mypy output on CI for easier reading
EliahKaganMar 9, 2024
84fc806
Remove some unneeded mypy suppressions
EliahKaganMar 10, 2024
96ecc2e
Drop deprecated mypy option
EliahKaganMar 10, 2024
97d9b65
Apply intended suppression in Tree.traverse
EliahKaganMar 10, 2024
ad00c77
Spell self.Index as self.INDEX in IndexFile.diff
EliahKaganMar 10, 2024
2decbe4
Test that redefined Diffable.Index should be compatible
EliahKaganMar 10, 2024
88557bc
Have git module use sys.platform to check for Windows
EliahKaganMar 10, 2024
7204c13
Fix new mypy error in _read_win_env_flag
EliahKaganMar 10, 2024
42e10c0
Fix new mypy error in is_cygwin_git
EliahKaganMar 10, 2024
465ab56
Have test suite use sys.platform to check for Windows
EliahKaganMar 10, 2024
ad8190b
Wrap docstrings and comments in _safer_popen_windows
EliahKaganMar 10, 2024
b9d9e56
Further improve _safer_popen_windows doc
EliahKaganMar 10, 2024
04a2753
Temporarily rename Commit_ish to Old_commit_ish
EliahKaganMar 10, 2024
787f65c
Define and document AnyGitObject and (new) Commit_ish
EliahKaganMar 10, 2024
1fe4dc8
Define GitObjectTypeString and update Object to use it
EliahKaganMar 10, 2024
7328a00
Start fixing annotations that used the old Commit_ish
EliahKaganMar 10, 2024
191f4cf
Fix some annotations in git.repo.fun
EliahKaganMar 10, 2024
d1ce940
Remove extra `parents` param in Commit.__init__ docstring
EliahKaganMar 10, 2024
fe42ca7
Help tools know the type of a Commit's `parents`
EliahKaganMar 11, 2024
e66297a
Keep the type of a Commit's `parents` from being too narrow
EliahKaganMar 11, 2024
fe7f9f2
Fix remaining old Commit_ish annotations in git.repo.fun
EliahKaganMar 11, 2024
ab27827
Fix remaining old Commit_ish annotations in git.refs
EliahKaganMar 11, 2024
b4b6e1e
Fix IndexFile.commit `parent_commits` annotation
EliahKaganMar 11, 2024
5b2869f
Fix old Commit_ish annotations in git.remote
EliahKaganMar 11, 2024
1541c62
Start on fixing Submodule parent_commit annotations
EliahKaganMar 11, 2024
1f03e7f
Fix other submodule.base parent_commit annotations
EliahKaganMar 14, 2024
e66b8f1
Fix old Commit_ish annotation in RootModule
EliahKaganMar 14, 2024
93d19dc
Remove the temporary Old_commit_ish type
EliahKaganMar 14, 2024
ebcfced
Fix and deprecate Lit_commit_ish
EliahKaganMar 14, 2024
b070e93
Make some broad mypy suppressions more specific
EliahKaganMar 14, 2024
0b99041
Merge branch 'main' into doc-types
EliahKaganMar 14, 2024
011cb0a
Apply Ruff auto-fixes not included in merge
EliahKaganMar 14, 2024
74f3c2e
Help Ruff avoid a very long line
EliahKaganMar 14, 2024
5778b7a
Use LBYL for imports where EAFP is a mypy type error
EliahKaganMar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions.github/workflows/pythonpackage.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,9 +88,12 @@ jobs:

- name: Check types with mypy
run: |
mypy -p git
# With new versions of mypy new issues might arise. This is a problem if there is nobody able to fix them,
# so we have to ignore errors until that changes.
mypy --python-version=${{ matrix.python-version }} -p git
env:
MYPY_FORCE_COLOR: "1"
TERM: "xterm-256color" # For color: https://github.com/python/mypy/issues/13817
# With new versions of mypy new issues might arise. This is a problem if there is
# nobody able to fix them, so we have to ignore errors until that changes.
continue-on-error: true

- name: Test with pytest
Expand Down
79 changes: 40 additions & 39 deletionsgit/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,38 +5,6 @@

# @PydevCodeAnalysisIgnore

__version__ = "git"

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
BlockingLockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# __all__ must be statically defined by py.typed support
# __all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
__all__ = [ # noqa: F405
"Actor",
"AmbiguousObjectName",
Expand All@@ -52,6 +20,7 @@
"CommandError",
"Commit",
"Diff",
"DiffConstants",
"DiffIndex",
"Diffable",
"FetchInfo",
Expand All@@ -65,18 +34,19 @@
"HEAD",
"Head",
"HookExecutionError",
"INDEX",
"IndexEntry",
"IndexFile",
"IndexObject",
"InvalidDBRoot",
"InvalidGitRepositoryError",
"List",
"List", # Deprecated - import this from `typing` instead.
"LockFile",
"NULL_TREE",
"NoSuchPathError",
"ODBError",
"Object",
"Optional",
"Optional", # Deprecated - import this from `typing` instead.
"ParseError",
"PathLike",
"PushInfo",
Expand All@@ -90,31 +60,62 @@
"RepositoryDirtyError",
"RootModule",
"RootUpdateProgress",
"Sequence",
"Sequence", # Deprecated - import from `typing`, or `collections.abc` in 3.9+.
"StageType",
"Stats",
"Submodule",
"SymbolicReference",
"TYPE_CHECKING",
"TYPE_CHECKING", # Deprecated - import this from `typing` instead.
"Tag",
"TagObject",
"TagReference",
"Tree",
"TreeModifier",
"Tuple",
"Union",
"Tuple", # Deprecated - import this from `typing` instead.
"Union", # Deprecated - import this from `typing` instead.
"UnmergedEntriesError",
"UnsafeOptionError",
"UnsafeProtocolError",
"UnsupportedOperation",
"UpdateProgress",
"WorkTreeRepositoryUnsupported",
"refresh",
"remove_password_if_present",
"rmtree",
"safe_decode",
"to_hex_sha",
]

__version__ = "git"

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
BlockingLockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# { Initialize git executable path
GIT_OK = None

Expand DownExpand Up@@ -146,7 +147,7 @@ def refresh(path: Optional[PathLike] = None) -> None:
if not Git.refresh(path=path):
return
if not FetchInfo.refresh(): # noqa: F405
return # type: ignore[unreachable]
return # type: ignore[unreachable]

GIT_OK = True

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp