github3-utils 0.6.1__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {github3_utils-0.6.1 → github3_utils-0.7.1}/PKG-INFO +10 -8
- {github3_utils-0.6.1 → github3_utils-0.7.1}/README.rst +4 -4
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/__init__.py +9 -7
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/apps.py +3 -1
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/check_labels.py +6 -2
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/click.py +1 -1
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/headers.py +3 -2
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/secrets.py +5 -7
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/testing.py +1 -1
- {github3_utils-0.6.1 → github3_utils-0.7.1}/pyproject.toml +10 -9
- github3_utils-0.7.1/requirements.txt +9 -0
- github3_utils-0.6.1/github3_utils/_typing.py +0 -54
- github3_utils-0.6.1/github3_utils/_typing.pyi +0 -4
- github3_utils-0.6.1/requirements.txt +0 -9
- {github3_utils-0.6.1 → github3_utils-0.7.1}/LICENSE +0 -0
- {github3_utils-0.6.1 → github3_utils-0.7.1}/github3_utils/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: github3-utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Handy utilities for github3.py
|
|
5
5
|
Author-email: Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
6
6
|
License: MIT
|
|
@@ -22,20 +22,22 @@ Classifier: Programming Language :: Python :: 3.6
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.7
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.8
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.9
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
27
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
28
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
29
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
30
|
Classifier: Typing :: Typed
|
|
29
31
|
Requires-Python: >=3.6
|
|
30
|
-
Requires-Dist: apeye>=0.
|
|
32
|
+
Requires-Dist: apeye-core>=1.0.0
|
|
31
33
|
Requires-Dist: attrs>=20.3.0
|
|
32
34
|
Requires-Dist: click>=7.1.2
|
|
33
|
-
Requires-Dist: cryptography
|
|
35
|
+
Requires-Dist: cryptography<40; implementation_name == "pypy" and python_version <= "3.7"
|
|
34
36
|
Requires-Dist: domdf-python-tools>=1.1.0
|
|
35
37
|
Requires-Dist: github3-py>=1.3.0
|
|
36
38
|
Requires-Dist: pynacl>=1.4.0
|
|
37
39
|
Requires-Dist: requests>=2.25.1
|
|
38
|
-
Requires-Dist: typing-extensions
|
|
40
|
+
Requires-Dist: typing-extensions!=3.10.0.1,>=3.10.0.0
|
|
39
41
|
Requires-Dist: betamax>=0.8.1; extra == 'testing'
|
|
40
42
|
Requires-Dist: pytest>=6.0.0; extra == 'testing'
|
|
41
43
|
Requires-Dist: betamax>=0.8.1; extra == 'all'
|
|
@@ -105,8 +107,8 @@ github3-utils
|
|
|
105
107
|
:target: https://github.com/domdfcoding/github3-utils/actions?query=workflow%3A%22mypy%22
|
|
106
108
|
:alt: mypy status
|
|
107
109
|
|
|
108
|
-
.. |requires| image:: https://dependency-dash.
|
|
109
|
-
:target: https://dependency-dash.
|
|
110
|
+
.. |requires| image:: https://dependency-dash.repo-helper.uk/github/domdfcoding/github3-utils/badge.svg
|
|
111
|
+
:target: https://dependency-dash.repo-helper.uk/github/domdfcoding/github3-utils/
|
|
110
112
|
:alt: Requirements Status
|
|
111
113
|
|
|
112
114
|
.. |coveralls| image:: https://img.shields.io/coveralls/github/domdfcoding/github3-utils/master?logo=coveralls
|
|
@@ -148,7 +150,7 @@ github3-utils
|
|
|
148
150
|
.. |language| image:: https://img.shields.io/github/languages/top/domdfcoding/github3-utils
|
|
149
151
|
:alt: GitHub top language
|
|
150
152
|
|
|
151
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/github3-utils/v0.
|
|
153
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/github3-utils/v0.7.1
|
|
152
154
|
:target: https://github.com/domdfcoding/github3-utils/pulse
|
|
153
155
|
:alt: GitHub commits since tagged version
|
|
154
156
|
|
|
@@ -156,7 +158,7 @@ github3-utils
|
|
|
156
158
|
:target: https://github.com/domdfcoding/github3-utils/commit/master
|
|
157
159
|
:alt: GitHub last commit
|
|
158
160
|
|
|
159
|
-
.. |maintained| image:: https://img.shields.io/maintenance/yes/
|
|
161
|
+
.. |maintained| image:: https://img.shields.io/maintenance/yes/2023
|
|
160
162
|
:alt: Maintenance
|
|
161
163
|
|
|
162
164
|
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/github3-utils
|
|
@@ -58,8 +58,8 @@ github3-utils
|
|
|
58
58
|
:target: https://github.com/domdfcoding/github3-utils/actions?query=workflow%3A%22mypy%22
|
|
59
59
|
:alt: mypy status
|
|
60
60
|
|
|
61
|
-
.. |requires| image:: https://dependency-dash.
|
|
62
|
-
:target: https://dependency-dash.
|
|
61
|
+
.. |requires| image:: https://dependency-dash.repo-helper.uk/github/domdfcoding/github3-utils/badge.svg
|
|
62
|
+
:target: https://dependency-dash.repo-helper.uk/github/domdfcoding/github3-utils/
|
|
63
63
|
:alt: Requirements Status
|
|
64
64
|
|
|
65
65
|
.. |coveralls| image:: https://img.shields.io/coveralls/github/domdfcoding/github3-utils/master?logo=coveralls
|
|
@@ -101,7 +101,7 @@ github3-utils
|
|
|
101
101
|
.. |language| image:: https://img.shields.io/github/languages/top/domdfcoding/github3-utils
|
|
102
102
|
:alt: GitHub top language
|
|
103
103
|
|
|
104
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/github3-utils/v0.
|
|
104
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/github3-utils/v0.7.1
|
|
105
105
|
:target: https://github.com/domdfcoding/github3-utils/pulse
|
|
106
106
|
:alt: GitHub commits since tagged version
|
|
107
107
|
|
|
@@ -109,7 +109,7 @@ github3-utils
|
|
|
109
109
|
:target: https://github.com/domdfcoding/github3-utils/commit/master
|
|
110
110
|
:alt: GitHub last commit
|
|
111
111
|
|
|
112
|
-
.. |maintained| image:: https://img.shields.io/maintenance/yes/
|
|
112
|
+
.. |maintained| image:: https://img.shields.io/maintenance/yes/2023
|
|
113
113
|
:alt: Maintenance
|
|
114
114
|
|
|
115
115
|
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/github3-utils
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# __init__.py
|
|
4
4
|
"""
|
|
5
|
-
Handy utilities for `github3.py <https://
|
|
5
|
+
Handy utilities for `github3.py <https://github3.readthedocs.io/en/latest/>`_.
|
|
6
6
|
"""
|
|
7
7
|
#
|
|
8
8
|
# Copyright © 2020 Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
@@ -60,7 +60,7 @@ from typing import Iterable, Iterator, List, Optional, Union, overload
|
|
|
60
60
|
|
|
61
61
|
# 3rd party
|
|
62
62
|
import attr
|
|
63
|
-
from
|
|
63
|
+
from apeye_core import URL
|
|
64
64
|
from click import echo
|
|
65
65
|
from github3 import GitHub
|
|
66
66
|
from github3.orgs import Organization
|
|
@@ -70,15 +70,15 @@ from github3.users import User
|
|
|
70
70
|
from typing_extensions import Literal
|
|
71
71
|
|
|
72
72
|
# this package
|
|
73
|
-
from github3_utils.headers import
|
|
73
|
+
from github3_utils.headers import LUKE_CAGE
|
|
74
74
|
|
|
75
75
|
__author__: str = "Dominic Davis-Foster"
|
|
76
76
|
__copyright__: str = "2020 Dominic Davis-Foster"
|
|
77
77
|
__license__: str = "MIT License"
|
|
78
|
-
__version__: str = "0.
|
|
78
|
+
__version__: str = "0.7.1"
|
|
79
79
|
__email__: str = "dominic@davis-foster.co.uk"
|
|
80
80
|
|
|
81
|
-
__all__ =
|
|
81
|
+
__all__ = (
|
|
82
82
|
"RateLimitExceeded",
|
|
83
83
|
"echo_rate_limit",
|
|
84
84
|
"get_user",
|
|
@@ -86,7 +86,7 @@ __all__ = [
|
|
|
86
86
|
"Impersonate",
|
|
87
87
|
"get_repos",
|
|
88
88
|
"iter_repos",
|
|
89
|
-
|
|
89
|
+
)
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
class RateLimitExceeded(RuntimeError):
|
|
@@ -179,7 +179,7 @@ def protect_branch(branch: Branch, status_checks: Optional[List[str]] = None) ->
|
|
|
179
179
|
resp = branch._put(
|
|
180
180
|
str(URL(branch._api) / "protection"),
|
|
181
181
|
json=edit,
|
|
182
|
-
headers=
|
|
182
|
+
headers=LUKE_CAGE,
|
|
183
183
|
)
|
|
184
184
|
|
|
185
185
|
if branch._boolean(resp, 200, 404):
|
|
@@ -305,6 +305,7 @@ def iter_repos(
|
|
|
305
305
|
:param orgs: An iterable of organization names to fetch the repositories for.
|
|
306
306
|
"""
|
|
307
307
|
|
|
308
|
+
# pylint: disable=loop-invariant-statement
|
|
308
309
|
for user in users:
|
|
309
310
|
_user: Optional[User] = github.user(user)
|
|
310
311
|
if _user is None:
|
|
@@ -319,3 +320,4 @@ def iter_repos(
|
|
|
319
320
|
raise ValueError(f"No such organization {org}")
|
|
320
321
|
|
|
321
322
|
yield from get_repos(_org, full=False)
|
|
323
|
+
# pylint: enable=loop-invariant-statement
|
|
@@ -41,7 +41,7 @@ from typing_extensions import Literal
|
|
|
41
41
|
# this package
|
|
42
42
|
from github3_utils.headers import MACHINE_MAN
|
|
43
43
|
|
|
44
|
-
__all__ =
|
|
44
|
+
__all__ = ("ContextSwitcher", "iter_installed_repos", "make_footer_links")
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
@attr.s
|
|
@@ -127,6 +127,8 @@ def iter_installed_repos(
|
|
|
127
127
|
:param private_key_pem: The bytes of the private key for this GitHub App.
|
|
128
128
|
:param app_id: The integer identifier for this GitHub App.
|
|
129
129
|
|
|
130
|
+
.. latex:clearpage::
|
|
131
|
+
|
|
130
132
|
Either ``context_switcher`` or all of ``client``, ``private_key_pem`` and ``app_id`` must be provided.
|
|
131
133
|
"""
|
|
132
134
|
|
|
@@ -42,7 +42,7 @@ from github3.pulls import PullRequest, ShortPullRequest
|
|
|
42
42
|
from github3.repos import Repository
|
|
43
43
|
from github3.repos.commit import ShortCommit
|
|
44
44
|
|
|
45
|
-
__all__ =
|
|
45
|
+
__all__ = ("Label", "check_status_labels", "Checks", "get_checks_for_pr", "label_pr_failures")
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
@prettify_docstrings
|
|
@@ -133,6 +133,7 @@ def get_checks_for_pr(pull: Union[PullRequest, ShortPullRequest]) -> Checks:
|
|
|
133
133
|
check_run: CheckRun
|
|
134
134
|
for check_run in head_commit.check_runs():
|
|
135
135
|
|
|
136
|
+
# pylint: disable=loop-invariant-statement
|
|
136
137
|
if check_run.status in {"queued", "running", "in_progress"}:
|
|
137
138
|
running.add(check_run.name)
|
|
138
139
|
elif check_run.conclusion in {"failure", "cancelled", "timed_out", "action_required"}:
|
|
@@ -143,6 +144,7 @@ def get_checks_for_pr(pull: Union[PullRequest, ShortPullRequest]) -> Checks:
|
|
|
143
144
|
skipped.add(check_run.name)
|
|
144
145
|
elif check_run.conclusion == "neutral":
|
|
145
146
|
neutral.add(check_run.name)
|
|
147
|
+
# pylint: enable=loop-invariant-statement
|
|
146
148
|
|
|
147
149
|
# Remove failing checks from successful etc. (as all checks appear twice for PRs)
|
|
148
150
|
successful = successful - failing - running
|
|
@@ -178,9 +180,10 @@ def label_pr_failures(pull: Union[PullRequest, ShortPullRequest]) -> Set[str]:
|
|
|
178
180
|
|
|
179
181
|
def determine_labels(from_: Set[str], to: Set[str]) -> None:
|
|
180
182
|
for check in from_:
|
|
181
|
-
if _python_dev_re.match(check):
|
|
183
|
+
if _python_dev_re.match(check): # pylint: disable=loop-global-usage
|
|
182
184
|
continue
|
|
183
185
|
|
|
186
|
+
# pylint: disable=loop-invariant-statement
|
|
184
187
|
if check in {"Flake8", "docs"}:
|
|
185
188
|
to.add(f"failure: {check.lower()}")
|
|
186
189
|
elif check.startswith("mypy"):
|
|
@@ -189,6 +192,7 @@ def label_pr_failures(pull: Union[PullRequest, ShortPullRequest]) -> Set[str]:
|
|
|
189
192
|
to.add("failure: Linux")
|
|
190
193
|
elif check.startswith("windows"):
|
|
191
194
|
to.add("failure: Windows")
|
|
195
|
+
# pylint: enable=loop-invariant-statement
|
|
192
196
|
|
|
193
197
|
determine_labels(pr_checks.failing, failure_labels)
|
|
194
198
|
determine_labels(pr_checks.successful, success_labels)
|
|
@@ -28,7 +28,8 @@ GitHub-specific custom HTTP headers.
|
|
|
28
28
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
#
|
|
30
30
|
|
|
31
|
-
__all__ =
|
|
31
|
+
__all__ = ("LUKE_CAGE", "MACHINE_MAN")
|
|
32
32
|
|
|
33
|
-
LUKE_CAKE
|
|
33
|
+
# There was a typo. It used to say LUKE_CAKE. Keep the old name to avoid breakage.
|
|
34
|
+
LUKE_CAKE = LUKE_CAGE = {"Accept": "application/vnd.github.luke-cage-preview+json"}
|
|
34
35
|
MACHINE_MAN = {"Accept": "application/vnd.github.machine-man-preview+json"}
|
|
@@ -31,22 +31,20 @@ from base64 import b64encode
|
|
|
31
31
|
from typing import List
|
|
32
32
|
|
|
33
33
|
# 3rd party
|
|
34
|
-
from
|
|
34
|
+
from apeye_core import URL
|
|
35
35
|
from github3.repos import Repository
|
|
36
36
|
from nacl import encoding, public
|
|
37
37
|
from requests import Response
|
|
38
|
+
from typing_extensions import TypedDict
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
from github3_utils._typing import make_typed_dict
|
|
41
|
-
|
|
42
|
-
__all__ = [
|
|
40
|
+
__all__ = (
|
|
43
41
|
"build_secrets_url",
|
|
44
42
|
"encrypt_secret",
|
|
45
43
|
"get_public_key",
|
|
46
44
|
"get_secrets",
|
|
47
45
|
"set_secret",
|
|
48
46
|
"PublicKey",
|
|
49
|
-
|
|
47
|
+
)
|
|
50
48
|
|
|
51
49
|
|
|
52
50
|
def build_secrets_url(repo: Repository) -> URL:
|
|
@@ -63,7 +61,7 @@ def build_secrets_url(repo: Repository) -> URL:
|
|
|
63
61
|
return URL(repo._build_url("actions/secrets", base_url=repo._api))
|
|
64
62
|
|
|
65
63
|
|
|
66
|
-
_PublicKey =
|
|
64
|
+
_PublicKey = TypedDict("_PublicKey", {"ETag": str, "Last-Modified": str}, total=False)
|
|
67
65
|
|
|
68
66
|
|
|
69
67
|
class PublicKey(_PublicKey):
|
|
@@ -51,7 +51,7 @@ from _pytest.fixtures import FixtureRequest # nodep
|
|
|
51
51
|
from betamax import Betamax # type: ignore[import] # nodep
|
|
52
52
|
from github3 import GitHub
|
|
53
53
|
|
|
54
|
-
__all__ =
|
|
54
|
+
__all__ = ("cassette", "github_client", "module_cassette")
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
@pytest.fixture()
|
|
@@ -4,21 +4,21 @@ build-backend = "whey"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "github3-utils"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7.1"
|
|
8
8
|
description = "Handy utilities for github3.py"
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
keywords = [ "github",]
|
|
11
11
|
dynamic = []
|
|
12
12
|
dependencies = [
|
|
13
|
-
"apeye>=0.
|
|
13
|
+
"apeye-core>=1.0.0",
|
|
14
14
|
"attrs>=20.3.0",
|
|
15
15
|
"click>=7.1.2",
|
|
16
|
-
'cryptography
|
|
16
|
+
'cryptography<40; implementation_name == "pypy" and python_version <= "3.7"',
|
|
17
17
|
"domdf-python-tools>=1.1.0",
|
|
18
18
|
"github3-py>=1.3.0",
|
|
19
19
|
"pynacl>=1.4.0",
|
|
20
20
|
"requests>=2.25.1",
|
|
21
|
-
"typing-extensions
|
|
21
|
+
"typing-extensions!=3.10.0.1,>=3.10.0.0",
|
|
22
22
|
]
|
|
23
23
|
classifiers = [
|
|
24
24
|
"Development Status :: 4 - Beta",
|
|
@@ -27,6 +27,8 @@ classifiers = [
|
|
|
27
27
|
"Operating System :: OS Independent",
|
|
28
28
|
"Programming Language :: Python",
|
|
29
29
|
"Programming Language :: Python :: 3 :: Only",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
30
32
|
"Programming Language :: Python :: 3.6",
|
|
31
33
|
"Programming Language :: Python :: 3.7",
|
|
32
34
|
"Programming Language :: Python :: 3.8",
|
|
@@ -63,7 +65,7 @@ base-classifiers = [
|
|
|
63
65
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
64
66
|
"Typing :: Typed",
|
|
65
67
|
]
|
|
66
|
-
python-versions = [ "3.6", "3.7", "3.8", "3.9",]
|
|
68
|
+
python-versions = [ "3.6", "3.7", "3.8", "3.9", "3.10", "3.11",]
|
|
67
69
|
python-implementations = [ "CPython", "PyPy",]
|
|
68
70
|
platforms = [ "Windows", "macOS", "Linux",]
|
|
69
71
|
license-key = "MIT"
|
|
@@ -90,6 +92,7 @@ extensions = [
|
|
|
90
92
|
"sphinx_toolbox.more_autosummary",
|
|
91
93
|
"sphinx_toolbox.documentation_summary",
|
|
92
94
|
"sphinx_toolbox.tweaks.param_dash",
|
|
95
|
+
"sphinxcontrib.toctree_plus",
|
|
93
96
|
"sphinx_toolbox.tweaks.latex_layout",
|
|
94
97
|
"sphinx_toolbox.tweaks.latex_toc",
|
|
95
98
|
"sphinx.ext.intersphinx",
|
|
@@ -100,7 +103,6 @@ extensions = [
|
|
|
100
103
|
"notfound.extension",
|
|
101
104
|
"sphinx_copybutton",
|
|
102
105
|
"sphinxcontrib.default_values",
|
|
103
|
-
"sphinxcontrib.toctree_plus",
|
|
104
106
|
"sphinx_debuginfo",
|
|
105
107
|
"sphinx_licenseinfo",
|
|
106
108
|
"seed_intersphinx_mapping",
|
|
@@ -108,8 +110,7 @@ extensions = [
|
|
|
108
110
|
"attr_utils.autoattrs",
|
|
109
111
|
"attr_utils.annotations",
|
|
110
112
|
"sphinx_autofixture",
|
|
111
|
-
"
|
|
112
|
-
"sphinx_toolbox_experimental.needspace",
|
|
113
|
+
"sphinx_toolbox.more_autosummary.column_widths",
|
|
113
114
|
]
|
|
114
115
|
sphinxemoji_style = "twemoji"
|
|
115
116
|
gitstamp_fmt = "%d %b %Y"
|
|
@@ -161,7 +162,7 @@ autodoc_exclude_members = [
|
|
|
161
162
|
]
|
|
162
163
|
|
|
163
164
|
[tool.mypy]
|
|
164
|
-
python_version = "3.
|
|
165
|
+
python_version = "3.8"
|
|
165
166
|
namespace_packages = true
|
|
166
167
|
check_untyped_defs = true
|
|
167
168
|
warn_unused_ignores = true
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# stdlib
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
__all__ = ["make_typed_dict"]
|
|
5
|
-
|
|
6
|
-
if sys.version_info > (3, 9): # pragma: no cover (<py39)
|
|
7
|
-
# stdlib
|
|
8
|
-
from typing import TypedDict
|
|
9
|
-
|
|
10
|
-
make_typed_dict = TypedDict
|
|
11
|
-
|
|
12
|
-
else: # pragma: no cover (py39+)
|
|
13
|
-
# 3rd party
|
|
14
|
-
from typing_extensions import _TypedDictMeta
|
|
15
|
-
|
|
16
|
-
def make_typed_dict(typename, *args, total=True, **kwargs): # pragma: no cover
|
|
17
|
-
"""
|
|
18
|
-
Create a TypedDict.
|
|
19
|
-
|
|
20
|
-
Temporary fix until https://github.com/python/typing/issues/761 is merged.
|
|
21
|
-
|
|
22
|
-
:param typename:
|
|
23
|
-
:param args:
|
|
24
|
-
:param total:
|
|
25
|
-
:param kwargs:
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
# From CPython
|
|
29
|
-
# PSF Licensed
|
|
30
|
-
# Copyright Python Software Foundation
|
|
31
|
-
|
|
32
|
-
if args:
|
|
33
|
-
try:
|
|
34
|
-
fields, = args # allow the "_fields" keyword be passed
|
|
35
|
-
except ValueError:
|
|
36
|
-
raise TypeError(
|
|
37
|
-
f'TypedDict.__new__() takes from 2 to 3 positional arguments but {len(args) + 2} were given'
|
|
38
|
-
)
|
|
39
|
-
else:
|
|
40
|
-
raise TypeError("TypedDict.__new__(): not enough arguments")
|
|
41
|
-
|
|
42
|
-
if fields is None:
|
|
43
|
-
fields = kwargs
|
|
44
|
-
elif kwargs:
|
|
45
|
-
raise TypeError("TypedDict takes either a dict or keyword arguments, but not both")
|
|
46
|
-
|
|
47
|
-
ns = {"__annotations__": dict(fields), "__total__": total}
|
|
48
|
-
try:
|
|
49
|
-
# Setting correct module is necessary to make typed dict classes pickleable.
|
|
50
|
-
ns["__module__"] = sys._getframe(1).f_globals.get("__name__", "__main__")
|
|
51
|
-
except (AttributeError, ValueError):
|
|
52
|
-
pass
|
|
53
|
-
|
|
54
|
-
return _TypedDictMeta(typename, (), ns, total=total)
|
|
File without changes
|
|
File without changes
|