Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Note that this does not undo the broader effect of the previous
commit, which is to make clear that subscripting a tree supports
both list-like and dict-like usage, not just list-like usage.
  • Loading branch information
EliahKagan committed Mar 3, 2024
commit 85889cde01292c2c4b041eb031f645a5fdf62f27
2 changes: 1 addition & 1 deletion git/objects/tree.py
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable):
R"""Tree objects represent an ordered list of :class:`~git.objects.blob.Blob`\s and
other :class:`Tree`\s.

Subscripting is supported, as with a mapping or sequence:
Subscripting is supported, as with a list or dict:

* Access a specific blob using the ``tree["filename"]`` notation.
* You may likewise access by index, like ``blob = tree[0]``.