Skip to content

Commit

Permalink
[CI] Fix typecheck in GHA (#22)
Browse files Browse the repository at this point in the history
Use Python 3.10 in Cirrus CI for typecheck
  • Loading branch information
abravalheri authored Mar 4, 2022
2 parents 1a418f8 + dfa2263 commit d313d5e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typecheck_task:
name: typecheck (Linux - 3.10)
only_if: $TYPE_CHECKING == 'true'
clone_script: *clone
container: {image: "python:3.9-bullseye"} # most recent => better type support
container: {image: "python:3.10-bullseye"} # most recent => better type support
pip_cache: *pip-cache
mypy_cache:
folder: .mypy_cache
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ testing =
pytest
pytest-cov

typecheck =
mypy
importlib-resources

[options.entry_points]
# Add here console scripts like:
console_scripts =
Expand Down
4 changes: 2 additions & 2 deletions src/validate_pyproject/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@


try: # pragma: no cover
if sys.version_info[:2] < (3, 7):
if sys.version_info[:2] < (3, 7) or TYPE_CHECKING: # See #22
from importlib_resources import files
else:
from importlib.resources import files # type: ignore[attr-defined]
from importlib.resources import files

def read_text(package: Union[str, ModuleType], resource) -> str:
return files(package).joinpath(resource).read_text(encoding="utf-8")
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ passenv =
# ^ ensure colors
extras =
all
deps =
mypy
typecheck
commands =
python -m mypy {posargs:src}

Expand Down

0 comments on commit d313d5e

Please sign in to comment.