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 <akuviljanen17@gmail.com>
This commit is contained in:
Sebastian Rittau
2021-06-18 16:05:23 +02:00
committed by GitHub
parent 5a256a0c70
commit bc2ec748f6
8 changed files with 9 additions and 12 deletions

View File

@@ -15,7 +15,6 @@
"stubs/openssl-python",
"stubs/pathlib2",
"stubs/pymssql",
"stubs/Routes",
"stubs/scribe",
"stubs/tornado"
],

View File

@@ -16,7 +16,6 @@
"stubs/openssl-python",
"stubs/pathlib2",
"stubs/pymssql",
"stubs/Routes",
"stubs/scribe",
"stubs/tornado",
// Modules that are incomplete in some way.

View File

@@ -5,4 +5,4 @@ flake8==3.9.2
flake8-bugbear==21.4.3
flake8-pyi==20.10.0
isort==5.8.0
pytype==2021.5.25
pytype==2021.06.17

View File

@@ -1,4 +1,5 @@
from . import mapper, util
from .mapper import Mapper as Mapper
from .util import URLGenerator as URLGenerator, redirect_to as redirect_to, url_for as url_for
class _RequestConfig:
def __getattr__(self, name): ...
@@ -7,8 +8,3 @@ class _RequestConfig:
def load_wsgi_environ(self, environ): ...
def request_config(original=...): ...
Mapper = mapper.Mapper
redirect_to = util.redirect_to
url_for = util.url_for
URLGenerator = util.URLGenerator

View File

@@ -1,3 +1 @@
version = "0.1"
python2 = true
python3 = false

View File

@@ -8,6 +8,7 @@ import sys
import tempfile
import toml
import venv
from glob import glob
from pathlib import Path
@@ -37,7 +38,7 @@ def run_stubtest(dist: Path) -> None:
metadata = dict(toml.loads(f.read()))
# Ignore stubs that don't support Python 2
if not bool(metadata.get("python3", True)):
if not bool(metadata.get("python3", True)) or not has_py3_stubs(dist):
return
with tempfile.TemporaryDirectory() as tmp:
@@ -105,6 +106,10 @@ def run_stubtest(dist: Path) -> None:
print(f"stubtest succeeded for {dist.name}", file=sys.stderr)
def has_py3_stubs(dist: Path) -> bool:
return len(glob(f"{dist}/*.pyi")) > 0 or len(glob(f"{dist}/[!@]*/__init__.pyi")) > 0
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--num-shards", type=int, default=1)