Skip to content

Drop 3.6, increase type strictness #1311

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

Merged
merged 36 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
39d37d5
replace some TBDs wiht runtime types
Yobmod Jul 31, 2021
c878771
replace more TBDs wiht runtime types
Yobmod Jul 31, 2021
009017e
Merge branch 'gitpython-developers:main' into main
Yobmod Aug 2, 2021
2163322
increase mypy strictness (warn unused ignored)
Yobmod Aug 2, 2021
0525c17
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Aug 2, 2021
91fce33
increase mypy strictness (warn unused ignored and warn unreachable)
Yobmod Aug 2, 2021
15ace87
rmv 3.6 from CI matrix
Yobmod Aug 2, 2021
bef2182
rmv 3.6 from setup.py
Yobmod Aug 2, 2021
270c3d7
rmv 3.6 README
Yobmod Aug 2, 2021
c3f3501
Add __future__.annotations to cmd.py
Yobmod Aug 2, 2021
829142d
Add __future__.annotations to cmd.py2
Yobmod Aug 2, 2021
13e0730
Fix parse_date typing
Yobmod Aug 2, 2021
730f119
Fix parse_date typing 2
Yobmod Aug 2, 2021
2fe13ca
Fix parse_date typing 3
Yobmod Aug 2, 2021
024b696
Fix parse_date typing 4
Yobmod Aug 2, 2021
e2f8367
Fix parse_date typing 5
Yobmod Aug 2, 2021
d30bc07
Fix parse_date typing 6
Yobmod Aug 2, 2021
6470ad4
Fix parse_date typing 7
Yobmod Aug 2, 2021
481f672
Add __future__.annotations to repo/base.py
Yobmod Aug 2, 2021
9de7310
Minor type fixes
Yobmod Aug 2, 2021
5647d58
Merge branch 'gitpython-developers:main' into main
Yobmod Aug 2, 2021
f34a39f
Test new union syntax (Pep604)
Yobmod Aug 2, 2021
3b53d28
Merge branch 'main' of https://github.com/Yobmod/GitPython
Yobmod Aug 2, 2021
4dd06c3
Test trailing comma in args (>py3.6?)
Yobmod Aug 2, 2021
94ae0c5
Test Dataclass in repo.base.blame()
Yobmod Aug 2, 2021
a3f5b13
Test Dataclass in repo.base.blame() 2
Yobmod Aug 2, 2021
a2a36e0
Test Dataclass in repo.base.blame() 3
Yobmod Aug 2, 2021
ed137cb
Test TypedDict in repo.base.blame() 2
Yobmod Aug 2, 2021
e4761ff
Test TypedDict in repo.base.blame() 1
Yobmod Aug 2, 2021
1aaa704
Test Dataclass in repo.base.blame() 4
Yobmod Aug 2, 2021
bc9bcf5
Test Dataclass in repo.base.blame() 5
Yobmod Aug 2, 2021
ad417ba
Test Dataclass in repo.base.blame() 6
Yobmod Aug 2, 2021
ecb1f79
Choose TypedDict!
Yobmod Aug 2, 2021
5aa8c34
Improve type of repo.blame_incremental()
Yobmod Aug 2, 2021
8b8aa16
Improve type of repo.currently_rebasing_on()
Yobmod Aug 2, 2021
84232f7
Add Typing :: Typed to setup.py
Yobmod Aug 3, 2021
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
Add __future__.annotations to repo/base.py
  • Loading branch information
Yobmod committed Aug 2, 2021
commit 481f672baab666d6e2f81e9288a5f3c42c884a8e
4 changes: 1 addition & 3 deletions git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
offset = -int(utcoffset.total_seconds())
return int(string_date.astimezone(utc).timestamp()), offset
else:
# should just return timestamp, 0?
return int(string_date.astimezone(utc).timestamp()), 0
# raise ValueError(f"string_date datetime object without tzinfo, {string_date}")
raise ValueError(f"string_date datetime object without tzinfo, {string_date}")

# git time
try:
Expand Down
12 changes: 8 additions & 4 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ def __str__(self) -> str:
def __repr__(self) -> str:
return '<git.%s "%s">' % (self.__class__.__name__, self.path)

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
if hasattr(other, 'path'):
other = cast(SymbolicReference, other)
return self.path == other.path
return False

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)

def __hash__(self) -> int:
Expand Down Expand Up @@ -364,8 +365,9 @@ def set_reference(self, ref: Union[Commit_ish, 'SymbolicReference', str],
return self

# aliased reference
reference: Union['Head', 'TagReference', 'RemoteReference', 'Reference']
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to") # type: ignore
ref: Union['Head', 'TagReference', 'RemoteReference', 'Reference'] = reference # type: ignore
ref = reference

def is_valid(self) -> bool:
"""
Expand Down Expand Up @@ -699,7 +701,9 @@ def from_path(cls, repo: 'Repo', path: PathLike) -> Union['Head', 'TagReference'
instance = ref_type(repo, path)
if instance.__class__ == SymbolicReference and instance.is_detached:
raise ValueError("SymbolRef was detached, we drop it")
return instance
else:
assert isinstance(instance, Reference), "instance should be Reference or subtype"
return instance
except ValueError:
pass
# END exception handling
Expand Down
2 changes: 1 addition & 1 deletion git/repo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Initialize the Repo package"""
# flake8: noqa
from .base import *
from .base import Repo as Repo
9 changes: 5 additions & 4 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
from __future__ import annotations
import logging
import os
import re
Expand Down Expand Up @@ -384,13 +385,13 @@ def create_submodule(self, *args: Any, **kwargs: Any) -> Submodule:
:return: created submodules"""
return Submodule.add(self, *args, **kwargs)

def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator:
def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
"""An iterator yielding Submodule instances, see Traversable interface
for a description of args and kwargs
:return: Iterator"""
return RootModule(self).traverse(*args, **kwargs)

def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator:
def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
"""Update the submodules, keeping the repository consistent as it will
take the previous state into consideration. For more information, please
see the documentation of RootModule.update"""
Expand Down Expand Up @@ -774,15 +775,15 @@ def _get_untracked_files(self, *args: Any, **kwargs: Any) -> List[str]:
finalize_process(proc)
return untracked_files

def ignored(self, *paths: PathLike) -> List[PathLike]:
def ignored(self, *paths: PathLike) -> List[str]:
"""Checks if paths are ignored via .gitignore
Doing so using the "git check-ignore" method.

:param paths: List of paths to check whether they are ignored or not
:return: subset of those paths which are ignored
"""
try:
proc = self.git.check_ignore(*paths)
proc: str = self.git.check_ignore(*paths)
except GitCommandError:
return []
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
Expand Down
2 changes: 1 addition & 1 deletion git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Most of these are unused here, but are for use by git-python modules so these
# don't see gitdb all the time. Flake of course doesn't like it.
__all__ = ["stream_copy", "join_path", "to_native_path_linux",
"join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
"join_path_native", "Stats", "IndexFileSHA1Writer", "IterableObj", "IterableList",
"BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists',
'RemoteProgress', 'CallableRemoteProgress', 'rmtree', 'unbare_repo',
'HIDE_WINDOWS_KNOWN_ERRORS']
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ filterwarnings = 'ignore::DeprecationWarning'
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
implicit_reexport = true
# warn_unused_ignores = true
warn_unreachable = true
show_error_codes = true
implicit_reexport = true
# strict = true

# TODO: remove when 'gitdb' is fully annotated
[[tool.mypy.overrides]]
Expand Down