Skip to content

Commit

Permalink
Move mypy from pre-commit to tox
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 10, 2024
1 parent 3c04f83 commit 9be9f71
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@ on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1

permissions:
contents: read

jobs:
lint:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
- uses: pre-commit/[email protected]

mypy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
- name: Install dependencies
run: python3 -m pip install -U tox
- name: Mypy
run: tox -e mypy
23 changes: 7 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
args: [--exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black

Expand All @@ -25,7 +25,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.6
rev: 0.29.2
hooks:
- id: check-github-workflows
- id: check-renovate
Expand All @@ -35,32 +35,23 @@ repos:
hooks:
- id: actionlint

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
hooks:
- id: mypy
args: [--strict, --pretty, --show-error-codes, .]
additional_dependencies:
[httpx, platformdirs, pytest, python-slugify, types-freezegun]
pass_filenames: false

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.4
rev: 2.2.3
hooks:
- id: pyproject-fmt

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
rev: v0.19
hooks:
- id: validate-pyproject

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
rev: 1.3.2
hooks:
- id: tox-ini-fmt

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ max_supported_python = "3.13"

[tool.pytest.ini_options]
addopts = "--color=yes"
testpaths = [ "tests" ]

[tool.mypy]
pretty = true
strict = true
show_error_codes = true
4 changes: 3 additions & 1 deletion src/linkotron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def __init__(self, text: str) -> None:
self.text = text
self.m: Any = None

def __eq__(self, pattern: Any) -> bool:
def __eq__(self, pattern: object) -> bool:
if not isinstance(pattern, re.Pattern):
return NotImplemented
self.m = re.fullmatch(pattern, self.text)
return bool(self.m)

Expand Down
2 changes: 1 addition & 1 deletion src/linkotron/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from . import __version__, shorten

try:
import pyperclip as copier # type: ignore[import-not-found]
import pyperclip as copier # type: ignore[import-untyped]
except ImportError:
try:
import xerox as copier # type: ignore[import-not-found]
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ pass_env =
PRE_COMMIT_COLOR
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:mypy]
deps =
httpx
mypy==1.10.1
platformdirs
pyperclip
pytest
python-slugify
types-freezegun
commands =
mypy . {posargs}

0 comments on commit 9be9f71

Please sign in to comment.