Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
ruff check tests


mypy:
name: mypy
typecheck:
name: ty typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -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
10 changes: 6 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Test: `pytest -vv` (all tests) or `pytest tests/test_<name>.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`

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ lint.select = [
"F",
"W",
]

[tool.ty]
# Type checking configuration with ty
3 changes: 1 addition & 2 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 4 additions & 19 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
11 changes: 2 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 3 additions & 4 deletions tests/test_dict2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading