FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
typeshed/tests/stubtest_stdlib.py at main · python/typeshed · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
typeshed
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
5.1k
Code
Issues
212
Pull requests
155
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
typeshed
/
tests
/
stubtest_stdlib.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
59 lines (50 loc) · 2.01 KB
Breadcrumbs
typeshed
/
tests
/
stubtest_stdlib.py
Copy path
File metadata and controls
executable file
·
59 lines (50 loc) · 2.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""Test typeshed's stdlib using stubtest.
stubtest is a script in the mypy project that compares stubs to the actual objects at runtime.
Note that therefore the output of stubtest depends on which Python version it is run with.
In typeshed CI, we run stubtest with each currently supported Python minor version.
"""
from
__future__
import
annotations
import
subprocess
import
sys
from
pathlib
import
Path
from
ts_utils
.
paths
import
TS_BASE_PATH
,
allowlists_path
from
ts_utils
.
utils
import
allowlist_stubtest_arguments
def
run_stubtest
(
typeshed_dir
:
Path
)
->
int
:
# Note when stubtest imports distutils, it will likely actually import setuptools._distutils
# This is fine because we don't care about distutils and allowlist all errors from it
# https://github.com/python/typeshed/pull/10253#discussion_r1216712404
# https://github.com/python/typeshed/pull/9734
cmd
=
[
sys
.
executable
,
"-m"
,
"mypy.stubtest"
,
"--check-typeshed"
,
"--show-traceback"
,
"--strict-type-check-only"
,
"--custom-typeshed-dir"
,
str
(
typeshed_dir
),
*
allowlist_stubtest_arguments
(
"stdlib"
),
]
print
(
" "
.
join
(
cmd
),
file
=
sys
.
stderr
)
try
:
subprocess
.
run
(
cmd
,
check
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
print
(
"
\n
NB: stubtest output depends on the Python version (and system) it is run with. "
+
"See README.md for more details.
\n
"
+
"NB: We only check positional-only arg accuracy for Python 3.10.
\n
"
+
f"
\n
Command run was:
{
' '
.
join
(
cmd
)
}
\n
"
,
file
=
sys
.
stderr
,
)
print
(
"
\n
\n
"
,
file
=
sys
.
stderr
)
print
(
f'To fix "unused allowlist" errors, remove the corresponding entries from
{
allowlists_path
(
"stdlib"
)
}
'
,
file
=
sys
.
stderr
,
)
return
e
.
returncode
else
:
print
(
"stubtest succeeded"
,
file
=
sys
.
stderr
)
return
0
if
__name__
==
"__main__"
:
sys
.
exit
(
run_stubtest
(
typeshed_dir
=
TS_BASE_PATH
))
Back
|
FazBrowse Home
|
New Git URL