Skip to content

Commit 9f12c8c

Browse files
muggenhorByron
authored andcommitted
fix(types): get the os.PathLike type as correctly as possible
This should make our internal PathLike type compatible with Python < 3.6 and < 3.9.
1 parent 0767cc5 commit 9f12c8c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎git/types.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
importos# @UnusedImport ## not really unused, is in type string
1+
# -*- coding: utf-8 -*-
2+
# This module is part of GitPython and is released under
3+
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
4+
5+
importos
6+
importsys
27
fromtypingimportUnion, Any
38

49

510
TBD=Any
6-
PathLike=Union[str, 'os.PathLike[str]']
11+
12+
ifsys.version_info[:2] < (3, 6):
13+
# os.PathLike (PEP-519) only got introduced with Python 3.6
14+
PathLike=str
15+
elifsys.version_info[:2] < (3, 9):
16+
# Python >= 3.6, < 3.9
17+
PathLike=Union[str, os.PathLike]
18+
elifsys.version_info[:2] >= (3, 9):
19+
# os.PathLike only becomes subscriptable from Python 3.9 onwards
20+
PathLike=Union[str, os.PathLike[str]]

0 commit comments

Comments
 (0)