chore: adding extra checks, more scoping (#867)
* chore: adding extra checks, more scoping * Remove 'manual' pre-commit checks from CI Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
bf36398572
commit
f511961b40
@@ -1,9 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
$PYTHON --version
|
$PYTHON --version
|
||||||
$PYTHON -m pip --version
|
$PYTHON -m pip --version
|
||||||
$PYTHON -m virtualenv -p $PYTHON venv
|
$PYTHON -m virtualenv -p "$PYTHON" venv
|
||||||
venv/bin/python -m pip install -e ".[dev]"
|
venv/bin/python -m pip install -e ".[dev]"
|
||||||
venv/bin/python -m pip freeze
|
venv/bin/python -m pip freeze
|
||||||
venv/bin/python --version
|
venv/bin/python --version
|
||||||
|
|||||||
+35
-16
@@ -52,32 +52,51 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
exclude: ^(bin|cibuildwheel/resources|docs)/.*py$
|
exclude: ^(bin|cibuildwheel/resources|docs)/.*py$
|
||||||
args: ["--python-version=3.6", "--scripts-are-modules"]
|
args: ["--python-version=3.6", "--scripts-are-modules", "--show-error-codes"]
|
||||||
additional_dependencies:
|
additional_dependencies: &mypy-dependencies
|
||||||
- packaging
|
- packaging>=21.0
|
||||||
- types-jinja2
|
- rich
|
||||||
- types-certifi
|
|
||||||
- types-toml
|
|
||||||
- tomli
|
- tomli
|
||||||
|
- types-certifi
|
||||||
|
- types-click
|
||||||
|
- types-jinja2
|
||||||
|
- types-pyyaml
|
||||||
|
- types-requests
|
||||||
- id: mypy
|
- id: mypy
|
||||||
name: mypy 3.7+ on bin/
|
name: mypy 3.7+ on bin/
|
||||||
files: ^((bin|docs)/.*py|noxfile.py)$
|
files: ^((bin|docs)/.*py|noxfile.py)$
|
||||||
args: ["--python-version=3.7", "--scripts-are-modules"]
|
args: ["--python-version=3.7", "--scripts-are-modules", "--show-error-codes"]
|
||||||
additional_dependencies:
|
additional_dependencies: *mypy-dependencies
|
||||||
- packaging>=21.0
|
|
||||||
- rich
|
- repo: https://github.com/asottile/yesqa
|
||||||
- types-jinja2
|
rev: v1.2.3
|
||||||
- types-pyyaml
|
hooks:
|
||||||
- types-click
|
- id: yesqa
|
||||||
- types-requests
|
additional_dependencies: &flake8-dependencies
|
||||||
- tomli
|
- flake8-bugbear
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 4.0.1
|
rev: 4.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
exclude: cibuildwheel/resources/
|
exclude: cibuildwheel/resources/
|
||||||
additional_dependencies: [flake8-bugbear]
|
additional_dependencies: *flake8-dependencies
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||||
|
rev: v1.9.0
|
||||||
|
hooks:
|
||||||
|
- id: python-check-blanket-noqa
|
||||||
|
stages: [manual]
|
||||||
|
- id: python-check-blanket-type-ignore
|
||||||
|
stages: [manual]
|
||||||
|
- id: python-no-log-warn
|
||||||
|
- id: python-no-eval
|
||||||
|
- id: python-use-type-annotations
|
||||||
|
|
||||||
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
|
rev: v0.7.2.1
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ def bump_version() -> None:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
print( 'Current version:', current_version) # noqa
|
print( 'Current version:', current_version) # noqa: E201 whitespace
|
||||||
new_version = input(' New version: ').strip()
|
new_version = input(' New version: ').strip()
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from typing import Iterator
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
import yaml
|
import yaml
|
||||||
from ghapi.core import GhApi, HTTP404NotFoundError # type: ignore
|
from ghapi.core import GhApi, HTTP404NotFoundError # type: ignore[import]
|
||||||
from rich import print
|
from rich import print
|
||||||
|
|
||||||
from cibuildwheel.projectfiles import Analyzer
|
from cibuildwheel.projectfiles import Analyzer
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class PyPyVersions:
|
|||||||
|
|
||||||
def update_version_windows(self, spec: Specifier) -> ConfigWinCP:
|
def update_version_windows(self, spec: Specifier) -> ConfigWinCP:
|
||||||
releases = [r for r in self.releases if spec.contains(r["python_version"])]
|
releases = [r for r in self.releases if spec.contains(r["python_version"])]
|
||||||
releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore
|
releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore[no-any-return]
|
||||||
releases = [r for r in releases if self.get_arch_file(r)]
|
releases = [r for r in releases if self.get_arch_file(r)]
|
||||||
|
|
||||||
if not releases:
|
if not releases:
|
||||||
@@ -156,7 +156,7 @@ class PyPyVersions:
|
|||||||
raise RuntimeError("Other archs not supported yet on macOS")
|
raise RuntimeError("Other archs not supported yet on macOS")
|
||||||
|
|
||||||
releases = [r for r in self.releases if spec.contains(r["python_version"])]
|
releases = [r for r in self.releases if spec.contains(r["python_version"])]
|
||||||
releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore
|
releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore[no-any-return]
|
||||||
|
|
||||||
if not releases:
|
if not releases:
|
||||||
raise RuntimeError(f"PyPy macOS {self.arch} not found for {spec}!")
|
raise RuntimeError(f"PyPy macOS {self.arch} not found for {spec}!")
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ def main() -> None:
|
|||||||
os.environ["CIBUILDWHEEL"] = "1"
|
os.environ["CIBUILDWHEEL"] = "1"
|
||||||
|
|
||||||
# Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print'
|
# Python is buffering by default when running on the CI platforms, giving problems interleaving subprocess call output with unflushed calls to 'print'
|
||||||
sys.stdout = Unbuffered(sys.stdout) # type: ignore
|
sys.stdout = Unbuffered(sys.stdout) # type: ignore[no-untyped-call,assignment]
|
||||||
|
|
||||||
print_preamble(platform, build_options)
|
print_preamble(platform, build_options)
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class ConfigOptions:
|
|||||||
# get the option from the environment, then the config file, then finally the default.
|
# get the option from the environment, then the config file, then finally the default.
|
||||||
# platform-specific options are preferred, if they're allowed.
|
# platform-specific options are preferred, if they're allowed.
|
||||||
result = _dig_first(
|
result = _dig_first(
|
||||||
(os.environ if env_plat else {}, plat_envvar), # type: ignore
|
(os.environ if env_plat else {}, plat_envvar), # type: ignore[arg-type]
|
||||||
(os.environ, envvar),
|
(os.environ, envvar),
|
||||||
(self.config_platform_options, name),
|
(self.config_platform_options, name),
|
||||||
(self.config_options, name),
|
(self.config_options, name),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Analyzer(ast.NodeVisitor):
|
|||||||
def visit(self, content: ast.AST) -> None:
|
def visit(self, content: ast.AST) -> None:
|
||||||
for node in ast.walk(content):
|
for node in ast.walk(content):
|
||||||
for child in ast.iter_child_nodes(node):
|
for child in ast.iter_child_nodes(node):
|
||||||
child.parent = node # type: ignore
|
child.parent = node # type: ignore[attr-defined]
|
||||||
super().visit(content)
|
super().visit(content)
|
||||||
|
|
||||||
def visit_keyword(self, node: ast.keyword) -> None:
|
def visit_keyword(self, node: ast.keyword) -> None:
|
||||||
@@ -35,7 +35,7 @@ class Analyzer(ast.NodeVisitor):
|
|||||||
if node.arg == "python_requires":
|
if node.arg == "python_requires":
|
||||||
# Must not be nested in an if or other structure
|
# Must not be nested in an if or other structure
|
||||||
# This will be Module -> Expr -> Call -> keyword
|
# This will be Module -> Expr -> Call -> keyword
|
||||||
if not hasattr(node.parent.parent.parent, "parent") and isinstance( # type: ignore
|
if not hasattr(node.parent.parent.parent, "parent") and isinstance( # type: ignore[attr-defined]
|
||||||
node.value, Constant
|
node.value, Constant
|
||||||
):
|
):
|
||||||
self.requires_python = get_constant(node.value)
|
self.requires_python = get_constant(node.value)
|
||||||
|
|||||||
@@ -157,18 +157,18 @@ class TestSelector(IdentifierSelector):
|
|||||||
|
|
||||||
# Taken from https://stackoverflow.com/a/107717
|
# Taken from https://stackoverflow.com/a/107717
|
||||||
class Unbuffered:
|
class Unbuffered:
|
||||||
def __init__(self, stream): # type: ignore
|
def __init__(self, stream): # type: ignore[no-untyped-def]
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
|
|
||||||
def write(self, data): # type: ignore
|
def write(self, data): # type: ignore[no-untyped-def]
|
||||||
self.stream.write(data)
|
self.stream.write(data)
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
def writelines(self, data): # type: ignore
|
def writelines(self, data): # type: ignore[no-untyped-def]
|
||||||
self.stream.writelines(data)
|
self.stream.writelines(data)
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
def __getattr__(self, attr): # type: ignore
|
def __getattr__(self, attr): # type: ignore[no-untyped-def]
|
||||||
return getattr(self.stream, attr)
|
return getattr(self.stream, attr)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -27,4 +27,4 @@ def pytest_collection_modifyitems(config, items) -> None:
|
|||||||
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
|
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
|
||||||
)
|
)
|
||||||
def build_frontend_env(request) -> Dict[str, str]:
|
def build_frontend_env(request) -> Dict[str, str]:
|
||||||
return request.param # type: ignore
|
return request.param # type: ignore[no-any-return]
|
||||||
|
|||||||
Reference in New Issue
Block a user