diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 795cc66..8814571 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,8 +27,8 @@ jobs: ruff check tests - mypy: - name: mypy + typecheck: + name: ty typecheck runs-on: ubuntu-latest steps: - name: Checkout @@ -37,11 +37,15 @@ jobs: uses: actions/setup-python@v5.2.0 with: python-version: '3.13' - cache: 'pip' - - run: pip install --upgrade mypy types-requests types-urllib3 - - name: mypy - uses: liskin/gh-problem-matcher-wrap@v2 + - name: Install uv + uses: astral-sh/setup-uv@v6 with: - linters: mypy - run: | - mypy json2xml + enable-cache: true + - name: Install dependencies + run: | + uv venv + uv pip install -e . + - name: Run ty + run: | + source .venv/bin/activate + uvx ty check json2xml tests diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 87ad070..322736d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -142,9 +142,11 @@ jobs: - name: Install dependencies run: | - uv pip install --system -e . - uv pip install --system mypy>=1.0.0 types-setuptools + uv venv + uv pip install -e . - - name: Run mypy - run: mypy json2xml tests + - name: Run ty + run: | + source .venv/bin/activate + uvx ty check json2xml tests diff --git a/AGENT.md b/AGENT.md index 00d410e..54d726f 100644 --- a/AGENT.md +++ b/AGENT.md @@ -4,7 +4,7 @@ - Test: `pytest -vv` (all tests) or `pytest tests/test_.py -vv` (single test file) - Test with coverage: `pytest --cov=json2xml --cov-report=xml:coverage/reports/coverage.xml --cov-report=term -xvs` - Lint: `ruff check json2xml tests` -- Type check: `mypy json2xml tests` +- Type check: `uvx ty check json2xml tests` - Test all Python versions: `tox` - Clean artifacts: `make clean` diff --git a/Makefile b/Makefile index 2834c67..bd98e2e 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,8 @@ lint: ## check style with ruff lint-fix: ## automatically fix ruff issues ruff check --fix json2xml tests -typecheck: ## check types with mypy - mypy json2xml tests +typecheck: ## check types with ty + uvx ty check json2xml tests test: ## run tests quickly with the default Python pytest --cov=json2xml --cov-report=xml:coverage/reports/coverage.xml --cov-report=term -xvs tests -n auto diff --git a/dev.py b/dev.py index cf89b93..e631580 100644 --- a/dev.py +++ b/dev.py @@ -37,7 +37,7 @@ def main() -> None: ], "Tests") if command in ("typecheck", "all"): - success &= run_command(["mypy", "json2xml", "tests"], "Type checking") + success &= run_command(["uvx", "ty", "check", "json2xml", "tests"], "Type checking") if command == "help": print("Usage: python dev.py [command]") diff --git a/pyproject.toml b/pyproject.toml index 19ab880..b163964 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,3 +72,6 @@ lint.select = [ "F", "W", ] + +[tool.ty] +# Type checking configuration with ty diff --git a/requirements-dev.in b/requirements-dev.in index 19e4e7a..a5f37aa 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -7,5 +7,4 @@ pytest-xdist==3.8.0 coverage==7.10.3 ruff==0.12.8 setuptools==80.9.0 -mypy==1.17.1 -types-setuptools==80.9.0.20250809 +# Note: ty is run via uvx, not installed as a dependency diff --git a/requirements-dev.txt b/requirements-dev.txt index 088aeb8..8112b67 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,6 @@ -# -# This file is autogenerated by pip-compile with Python 3.13 -# by the following command: -# -# pip-compile requirements-dev.in -# -coverage[toml]==7.10.3 +# This file was autogenerated by uv via the following command: +# uv pip compile requirements-dev.in -o requirements-dev.txt +coverage==7.10.3 # via # -r requirements-dev.in # pytest-cov @@ -14,14 +10,8 @@ execnet==2.1.1 # via pytest-xdist iniconfig==2.0.0 # via pytest -mypy==1.17.1 - # via -r requirements-dev.in -mypy-extensions==1.0.0 - # via mypy packaging==24.2 # via pytest -pathspec==0.12.1 - # via mypy pluggy==1.5.0 # via # pytest @@ -39,14 +29,9 @@ pytest-xdist==3.8.0 # via -r requirements-dev.in ruff==0.12.8 # via -r requirements-dev.in -types-setuptools==80.9.0.20250809 +setuptools==80.9.0 # via -r requirements-dev.in -typing-extensions==4.12.2 - # via mypy urllib3==2.5.0 # via -r requirements.in xmltodict==0.14.2 # via -r requirements-dev.in - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/setup.cfg b/setup.cfg index 7b679c0..d1da384 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,15 +21,8 @@ max-line-length=120 [aliases] # Define setup.py command aliases here -[mypy] -check_untyped_defs = true -disallow_any_generics = true -disallow_incomplete_defs = true -disallow_untyped_defs = true -no_implicit_optional = true -warn_redundant_casts = true -warn_unused_ignores = true -ignore_missing_imports = true +[tool.ty] +# Ty configuration is now in pyproject.toml [coverage:run] diff --git a/tests/test_dict2xml.py b/tests/test_dict2xml.py index df770a9..1d279f8 100644 --- a/tests/test_dict2xml.py +++ b/tests/test_dict2xml.py @@ -11,7 +11,6 @@ from _pytest.fixtures import FixtureRequest from _pytest.logging import LogCaptureFixture from _pytest.monkeypatch import MonkeyPatch - from pytest_mock.plugin import MockerFixture class TestDict2xml: @@ -808,8 +807,8 @@ def patched_get_unique_id(element: str) -> str: this_id = module.make_id(element) # This exercises line 52 return ids[-1] - module.make_id = mock_make_id - module.get_unique_id = patched_get_unique_id + module.make_id = mock_make_id # type: ignore[assignment] + module.get_unique_id = patched_get_unique_id # type: ignore[assignment] try: result = dicttoxml.get_unique_id("test") @@ -1025,7 +1024,7 @@ def mock_is_primitive(val: Any) -> bool: return True return original_is_primitive(val) - module.is_primitive_type = mock_is_primitive + module.is_primitive_type = mock_is_primitive # type: ignore[assignment] try: item = {"@val": {"test": "data"}} result = dicttoxml.dict2xml_str( diff --git a/tests/test_utils.py b/tests/test_utils.py index e98db99..f9346f2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -21,7 +21,6 @@ from _pytest.fixtures import FixtureRequest from _pytest.logging import LogCaptureFixture from _pytest.monkeypatch import MonkeyPatch - from pytest_mock.plugin import MockerFixture class TestExceptions: