Skip to content

Commit efd8b48

Browse files
committed
feat(downloads): add conditional dependency on literal for python 3.7
This supports commit c76b3b1 and makes sure it works on python 3.7 as well.
1 parent 4f9807f commit efd8b48

File tree

9 files changed

+60
-48
lines changed

9 files changed

+60
-48
lines changed

gitlab/mixins.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
import sys
1819
from types import ModuleType
1920
from typing import (
2021
Any,
2122
Callable,
2223
Dict,
2324
Iterator,
2425
List,
25-
Literal,
2626
Optional,
2727
Tuple,
2828
Type,
@@ -38,6 +38,11 @@
3838
from gitlab import types as g_types
3939
from gitlab import utils
4040

41+
if sys.version_info >= (3, 8):
42+
from typing import Literal
43+
else:
44+
from typing_extensions import Literal
45+
4146
__all__ = [
4247
"GetMixin",
4348
"GetWithoutIdMixin",

gitlab/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import pathlib
19+
import sys
1920
import traceback
2021
import urllib.parse
2122
import warnings
22-
from typing import Any, Callable, Dict, Iterator, Literal, Optional, Type, Union
23+
from typing import Any, Callable, Dict, Iterator, Optional, Type, Union
2324

2425
import requests
2526

27+
if sys.version_info >= (3, 8):
28+
from typing import Literal
29+
else:
30+
from typing_extensions import Literal
31+
2632

2733
class _StdoutStream:
2834
def __call__(self, chunk: Any) -> None:

gitlab/v4/objects/artifacts.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
GitLab API:
33
https://docs.gitlab.com/ee/api/job_artifacts.html
44
"""
5-
from typing import Any, Callable, Iterator, Literal, Optional, TYPE_CHECKING, Union
5+
import sys
6+
from typing import Any, Callable, Iterator, Optional, TYPE_CHECKING, Union
67

78
import requests
89

@@ -11,6 +12,11 @@
1112
from gitlab import utils
1213
from gitlab.base import RESTManager, RESTObject
1314

15+
if sys.version_info >= (3, 8):
16+
from typing import Literal
17+
else:
18+
from typing_extensions import Literal
19+
1420
__all__ = ["ProjectArtifact", "ProjectArtifactManager"]
1521

1622

gitlab/v4/objects/files.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import base64
2+
import sys
23
from typing import (
34
Any,
45
Callable,
56
cast,
67
Dict,
78
Iterator,
89
List,
9-
Literal,
1010
Optional,
1111
TYPE_CHECKING,
1212
Union,
@@ -27,6 +27,11 @@
2727
UpdateMixin,
2828
)
2929

30+
if sys.version_info >= (3, 8):
31+
from typing import Literal
32+
else:
33+
from typing_extensions import Literal
34+
3035
__all__ = [
3136
"ProjectFile",
3237
"ProjectFileManager",

gitlab/v4/objects/jobs.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
from typing import (
2-
Any,
3-
Callable,
4-
cast,
5-
Dict,
6-
Iterator,
7-
Literal,
8-
Optional,
9-
TYPE_CHECKING,
10-
Union,
11-
)
1+
import sys
2+
from typing import Any, Callable, cast, Dict, Iterator, Optional, TYPE_CHECKING, Union
123

134
import requests
145

@@ -18,6 +9,11 @@
189
from gitlab.base import RESTManager, RESTObject
1910
from gitlab.mixins import RefreshMixin, RetrieveMixin
2011

12+
if sys.version_info >= (3, 8):
13+
from typing import Literal
14+
else:
15+
from typing_extensions import Literal
16+
2117
__all__ = [
2218
"ProjectJob",
2319
"ProjectJobManager",

gitlab/v4/objects/packages.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
https://docs.gitlab.com/ee/user/packages/generic_packages/
55
"""
66

7+
import sys
78
from pathlib import Path
8-
from typing import (
9-
Any,
10-
Callable,
11-
cast,
12-
Iterator,
13-
Literal,
14-
Optional,
15-
TYPE_CHECKING,
16-
Union,
17-
)
9+
from typing import Any, Callable, cast, Iterator, Optional, TYPE_CHECKING, Union
1810

1911
import requests
2012

@@ -24,6 +16,11 @@
2416
from gitlab.base import RESTManager, RESTObject
2517
from gitlab.mixins import DeleteMixin, GetMixin, ListMixin, ObjectDeleteMixin
2618

19+
if sys.version_info >= (3, 8):
20+
from typing import Literal
21+
else:
22+
from typing_extensions import Literal
23+
2724
__all__ = [
2825
"GenericPackage",
2926
"GenericPackageManager",

gitlab/v4/objects/projects.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import sys
12
from typing import (
23
Any,
34
Callable,
45
cast,
56
Dict,
67
Iterator,
78
List,
8-
Literal,
99
Optional,
1010
TYPE_CHECKING,
1111
Union,
@@ -82,6 +82,11 @@
8282
from .variables import ProjectVariableManager # noqa: F401
8383
from .wikis import ProjectWikiManager # noqa: F401
8484

85+
if sys.version_info >= (3, 8):
86+
from typing import Literal
87+
else:
88+
from typing_extensions import Literal
89+
8590
__all__ = [
8691
"GroupProject",
8792
"GroupProjectManager",

gitlab/v4/objects/repositories.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,8 @@
33
44
Currently this module only contains repository-related methods for projects.
55
"""
6-
from typing import (
7-
Any,
8-
Callable,
9-
Dict,
10-
Iterator,
11-
List,
12-
Literal,
13-
Optional,
14-
TYPE_CHECKING,
15-
Union,
16-
)
6+
import sys
7+
from typing import Any, Callable, Dict, Iterator, List, Optional, TYPE_CHECKING, Union
178

189
import requests
1910

@@ -22,6 +13,11 @@
2213
from gitlab import exceptions as exc
2314
from gitlab import utils
2415

16+
if sys.version_info >= (3, 8):
17+
from typing import Literal
18+
else:
19+
from typing_extensions import Literal
20+
2521
if TYPE_CHECKING:
2622
# When running mypy we use these as the base classes
2723
_RestObjectBase = gitlab.base.RESTObject

gitlab/v4/objects/snippets.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
from typing import (
2-
Any,
3-
Callable,
4-
cast,
5-
Iterator,
6-
List,
7-
Literal,
8-
Optional,
9-
TYPE_CHECKING,
10-
Union,
11-
)
1+
import sys
2+
from typing import Any, Callable, cast, Iterator, List, Optional, TYPE_CHECKING, Union
123

134
import requests
145

@@ -22,6 +13,11 @@
2213
from .discussions import ProjectSnippetDiscussionManager # noqa: F401
2314
from .notes import ProjectSnippetNoteManager # noqa: F401
2415

16+
if sys.version_info >= (3, 8):
17+
from typing import Literal
18+
else:
19+
from typing_extensions import Literal
20+
2521
__all__ = [
2622
"Snippet",
2723
"SnippetManager",

0 commit comments

Comments
 (0)