comparison env/lib/python3.9/site-packages/packaging/_compat.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4 from __future__ import absolute_import, division, print_function
5
6 import sys
7
8 from ._typing import TYPE_CHECKING
9
10 if TYPE_CHECKING: # pragma: no cover
11 from typing import Any, Dict, Tuple, Type
12
13
14 PY2 = sys.version_info[0] == 2
15 PY3 = sys.version_info[0] == 3
16
17 # flake8: noqa
18
19 if PY3:
20 string_types = (str,)
21 else:
22 string_types = (basestring,)
23
24
25 def with_metaclass(meta, *bases):
26 # type: (Type[Any], Tuple[Type[Any], ...]) -> Any
27 """
28 Create a base class with a metaclass.
29 """
30 # This requires a bit of explanation: the basic idea is to make a dummy
31 # metaclass for one level of class instantiation that replaces itself with
32 # the actual metaclass.
33 class metaclass(meta): # type: ignore
34 def __new__(cls, name, this_bases, d):
35 # type: (Type[Any], str, Tuple[Any], Dict[Any, Any]) -> Any
36 return meta(name, bases, d)
37
38 return type.__new__(metaclass, "temporary_class", (), {})