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

Add flake8-typing-imports #1309

Merged
merged 1 commit into from
Aug 2, 2021
Merged

Add flake8-typing-imports #1309

merged 1 commit into from
Aug 2, 2021

Conversation

kasium
Copy link
Contributor

@kasium kasium commented Aug 2, 2021

The idea to include this plugin comes from #1095 . In short, flake8-typing-imports checks if a import from typing is possible in a certain python version.

I ran the plugin in your code base, and it's NOT compatible with <= 3.6.2. You use NamingTuple with defaults and NoReturn which were added in later patches of 3.6. To let in still run I set the minimum version to 3.7.0.

This means, that either we should fix the issues or gitpython needs to drop the support for this version which is anyway deprecated.
This plugin will hopefully prevent that any new issues are added

@kasium kasium mentioned this pull request Aug 2, 2021
@kasium
Copy link
Contributor Author

kasium commented Aug 2, 2021

Output for 3.6.0

git/types.py:7:1: TYP001 guard import by `if TYPE_CHECKING:`: NoReturn (not in 3.6.0, 3.6.1)
from typing import (Callable, Dict, NoReturn, Sequence, Tuple, Union, Any, Iterator,       # noqa: F401
^
git/index/base.py:70:1: TYP001 guard import by `if TYPE_CHECKING:`: NoReturn (not in 3.6.0, 3.6.1)
from typing import (Any, BinaryIO, Callable, Dict, IO, Iterable, Iterator, List, NoReturn,
^
git/index/typ.py:69:5: TYP005 NamedTuple does not support defaults in 3.6.0
    ctime_bytes: bytes = pack(">LL", 0, 0)
    ^
git/index/typ.py:70:5: TYP005 NamedTuple does not support defaults in 3.6.0
    mtime_bytes: bytes = pack(">LL", 0, 0)
    ^
git/index/typ.py:71:5: TYP005 NamedTuple does not support defaults in 3.6.0
    dev: int = 0
    ^
git/index/typ.py:72:5: TYP005 NamedTuple does not support defaults in 3.6.0
    inode: int = 0
    ^
git/index/typ.py:73:5: TYP005 NamedTuple does not support defaults in 3.6.0
    uid: int = 0
    ^
git/index/typ.py:74:5: TYP005 NamedTuple does not support defaults in 3.6.0
    gid: int = 0
    ^
git/index/typ.py:75:5: TYP005 NamedTuple does not support defaults in 3.6.0
    size: int = 0
    ^
git/objects/util.py:25:1: TYP001 guard import by `if TYPE_CHECKING:`: Deque (not in 3.6.0)
from typing import (Any, Callable, Deque, Iterator, NamedTuple, overload, Sequence,
^
git/refs/remote.py:12:1: TYP001 guard import by `if TYPE_CHECKING:`: NoReturn (not in 3.6.0, 3.6.1)
from typing import Any, Iterator, NoReturn, Union, TYPE_CHECKING
^
4     TYP001 guard import by `if TYPE_CHECKING:`: NoReturn (not in 3.6.0, 3.6.1)
7     TYP005 NamedTuple does not support defaults in 3.6.0
11

@Yobmod
Copy link
Contributor

Yobmod commented Aug 2, 2021

I've set the checks to run :)
Seems useful already!

So we have to decide: Drop 3.6 now, or i'll pull out NamedTuple defaults (there are only a couple of uses) for now.
NoReturn and Deque are available in typing_extensions, so that can be easily fixed.

I was planning to wait until 3.10 released to drop 3.6.
But I see it had it's final release this June and i have noticed big packages already dropping it (numpy and pandas and therefore most of scientific packages).
(Copying to issue for disucssion)

@Yobmod Yobmod merged commit d8a6398 into gitpython-developers:main Aug 2, 2021
@kasium kasium deleted the flake8-typing-imports branch August 2, 2021 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants