Skip to content

Use typing-extensions only on Python < 3.8 - #1218

Merged
Byron merged 2 commits into
gitpython-developers:mainfrom
mgorny:typing-ext
Apr 24, 2021
Merged

Use typing-extensions only on Python < 3.8#1218
Byron merged 2 commits into
gitpython-developers:mainfrom
mgorny:typing-ext

Conversation

@mgorny

Copy link
Copy Markdown
Contributor

All necessary attributes are available in the built-in typing module
since Python 3.8. Use typing-extensions only for older versions
of Python, and avoid the unnecessary dep in 3.8+.

@Byron

Copy link
Copy Markdown
Member

Thanks a lot!

Do you think that it would be possible to use git.compat.typing instead to avoid repeating the logic everywhere where typing is used? I don't know if re-exporting entire modules is possible.

@muggenhor

Copy link
Copy Markdown
Contributor

I think you meant git.types instead of git.compat.typing? The latter doesn't exist...

@Byron

Copy link
Copy Markdown
Member

I think this was a clumsy way of asking if there is a less redundant way of specifying the imports. In git.compat types are re-exported based on some logic, so code could rely on importing git.compat.typing alone without repeating any logic.

@muggenhor

Copy link
Copy Markdown
Contributor

Ah, like this?

# git/compat.py:ifsys.version_info[:2] >= (3, 8):
importtypingelse:
importtyping_extensionsastyping# elsewhere:from .compatimporttyping

Unfortunately that has the annoying side effect of not being able to do from git.compat.typing import Literal because git.compat.typing wouldn't be a package/module.

@mgorny
mgornyforce-pushed the typing-ext branch 2 times, most recently from f6d75c5 to db4bdb4CompareApril 23, 2021 14:17
@mgorny

Copy link
Copy Markdown
ContributorAuthor

@Byron, something like this? Or do you mean entirely replacing from typing ... with from git.compat.typing ...?

All necessary attributes are available in the built-in typing module
since Python 3.8. Use typing-extensions only for older versions
of Python, and avoid the unnecessary dep in 3.8+.
@ByronByron added this to the v3.1.16 - Bugfixes milestone Apr 24, 2021
@Byron
Byron merged commit 7301771 into gitpython-developers:mainApr 24, 2021
@Byron

Copy link
Copy Markdown
Member

Thank you very much for this contribution, this looks good to me, and I assume @muggenhor saw nothing that would prevent a merge either.

@mgorny
mgorny deleted the typing-ext branch April 24, 2021 06:39
@mgorny

Copy link
Copy Markdown
ContributorAuthor

Thanks! We're removing Python 3.7 support real soon from Gentoo, and so we're going to be one step closer to eliminating typing-extensions as well ;-).

@muggenhor

Copy link
Copy Markdown
Contributor

Thank you very much for this contribution, this looks good to me, and I assume @muggenhor saw nothing that would prevent a merge either.

Nope, didn't see any obstacles. It looks good!

Sign up for freeto 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.

3 participants

@mgorny@Byron@muggenhor