Skip to content
Snippets Groups Projects
Commit f98493ab authored by Hannes Feldt's avatar Hannes Feldt
Browse files

remove pre python 3.8 compat workarounds

parent 26136fce
Branches
No related tags found
1 merge request!89L2SS-1740: Move modules to prepare for statistics metadata
Pipeline #81924 failed
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# pylint: disable-all # pylint: disable-all
...@@ -8,32 +8,6 @@ ...@@ -8,32 +8,6 @@
Contains required methods missing in older python versions. Contains required methods missing in older python versions.
""" """
try:
# Python >=3.8 should have these functions already
from typing import get_args
from typing import get_origin
except ImportError:
import typing
import collections
def get_origin(tp):
"""Copied from the Python 3.8 typing module"""
if isinstance(tp, typing._GenericAlias):
return tp.__origin__
if tp is typing.Generic:
return typing.Generic
return None
def get_args(tp):
"""Copied from the Python 3.8 typing module"""
if isinstance(tp, typing._GenericAlias):
res = tp.__args__
if get_origin(tp) is collections.abc.Callable and res[0] is not Ellipsis:
res = (list(res[:-1]), res[-1])
return res
return ()
try: try:
from inspect import get_annotations from inspect import get_annotations
except ImportError: except ImportError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment