Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc2ec74

Browse files
srittauAkuli
andauthored
Move routes stubs to @python2 directory (#5637)
* Move routes stubs to @python2 directory * Ignore Python-2-only stubs for stubtest * Use standard idiom for re-exporting items Co-authored-by: Akuli <[email protected]>
1 parent 5a256a0 commit bc2ec74

8 files changed

Lines changed: 9 additions & 12 deletions

File tree

pyrightconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"stubs/openssl-python",
1616
"stubs/pathlib2",
1717
"stubs/pymssql",
18-
"stubs/Routes",
1918
"stubs/scribe",
2019
"stubs/tornado"
2120
],

pyrightconfig.stricter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"stubs/openssl-python",
1717
"stubs/pathlib2",
1818
"stubs/pymssql",
19-
"stubs/Routes",
2019
"stubs/scribe",
2120
"stubs/tornado",
2221
// Modules that are incomplete in some way.

requirements-tests-py3.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ flake8==3.9.2
55
flake8-bugbear==21.4.3
66
flake8-pyi==20.10.0
77
isort==5.8.0
8-
pytype==2021.5.25
8+
pytype==2021.06.17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from . import mapper, util
1+
from .mapper import Mapper as Mapper
2+
from .util import URLGenerator as URLGenerator, redirect_to as redirect_to, url_for as url_for
23

34
class _RequestConfig:
45
def __getattr__(self, name): ...
@@ -7,8 +8,3 @@ class _RequestConfig:
78
def load_wsgi_environ(self, environ): ...
89

910
def request_config(original=...): ...
10-
11-
Mapper = mapper.Mapper
12-
redirect_to = util.redirect_to
13-
url_for = util.url_for
14-
URLGenerator = util.URLGenerator

stubs/Routes/METADATA.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
version = "0.1"
2-
python2 = true
3-
python3 = false

tests/stubtest_third_party.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tempfile
99
import toml
1010
import venv
11+
from glob import glob
1112
from pathlib import Path
1213

1314

@@ -37,7 +38,7 @@ def run_stubtest(dist: Path) -> None:
3738
metadata = dict(toml.loads(f.read()))
3839

3940
# Ignore stubs that don't support Python 2
40-
if not bool(metadata.get("python3", True)):
41+
if not bool(metadata.get("python3", True)) or not has_py3_stubs(dist):
4142
return
4243

4344
with tempfile.TemporaryDirectory() as tmp:
@@ -105,6 +106,10 @@ def run_stubtest(dist: Path) -> None:
105106
print(f"stubtest succeeded for {dist.name}", file=sys.stderr)
106107

107108

109+
def has_py3_stubs(dist: Path) -> bool:
110+
return len(glob(f"{dist}/*.pyi")) > 0 or len(glob(f"{dist}/[!@]*/__init__.pyi")) > 0
111+
112+
108113
def main():
109114
parser = argparse.ArgumentParser()
110115
parser.add_argument("--num-shards", type=int, default=1)

0 commit comments

Comments
 (0)