Skip to content

Commit 1741df9

Browse files
committed
test mypy, unit test coverage
1 parent c2a52ad commit 1741df9

5 files changed

Lines changed: 116 additions & 9 deletions

File tree

.github/workflows/package-test.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ on:
99
- nightly
1010
- "releases/*"
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
Unit-Tests:
1417
timeout-minutes: 10
15-
runs-on: ${{ matrix.os }}
18+
runs-on: ubuntu-latest
1619
strategy:
1720
fail-fast: false
1821
matrix:
19-
os: [macos-latest, windows-latest, ubuntu-latest]
2022
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2123
steps:
2224
- uses: actions/checkout@v4
@@ -35,5 +37,19 @@ jobs:
3537
- name: Install dependencies
3638
run: poetry install --no-interaction
3739

38-
- name: Run Tests
39-
run: poetry run pytest tests
40+
- name: Type check (mypy)
41+
run: poetry run mypy python_obfuscator
42+
43+
- name: Run unit tests with coverage
44+
run: |
45+
poetry run coverage run -m pytest
46+
poetry run coverage report
47+
poetry run coverage xml
48+
49+
- name: Upload coverage reports to Codecov
50+
if: matrix.python-version == '3.12'
51+
uses: codecov/codecov-action@v5
52+
with:
53+
token: ${{ secrets.CODECOV_TOKEN }}
54+
slug: davidteather/python-obfuscator
55+
files: ./coverage.xml

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ python_obfuscator.egg-info
66
.pytest_cache
77
.mypy_cache
88
.ruff_cache
9-
obfuscated/
9+
obfuscated/
10+
.coverage
11+
coverage.xml
12+
htmlcov/

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ repos:
2424

2525
- repo: local
2626
hooks:
27+
- id: mypy
28+
name: mypy
29+
entry: poetry run mypy python_obfuscator
30+
language: system
31+
pass_filenames: false
32+
always_run: true
33+
stages: [commit]
34+
2735
- id: pytest-unit
2836
name: Run unit tests
2937
entry: poetry run pytest tests/ -v
@@ -32,6 +40,14 @@ repos:
3240
always_run: true
3341
stages: [commit]
3442

43+
- id: pytest-coverage-report
44+
name: pytest coverage report (manual)
45+
entry: poetry run pytest tests --cov=python_obfuscator --cov-report=term-missing --cov-report=html
46+
language: system
47+
pass_filenames: false
48+
always_run: true
49+
stages: [manual]
50+
3551
default_language_version:
3652
python: python3
3753

poetry.lock

Lines changed: 38 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ black = "^25.1.0"
1616
isort = "^6.0.0"
1717
pytest = "^8.3.4"
1818
coverage = "^7.6.12"
19+
pytest-cov = "^7.1.0"
20+
types-regex = "^2026.3.32.20260329"
1921

2022
[project]
2123
name = "python_obfuscator"
@@ -35,7 +37,15 @@ classifiers = [
3537
]
3638

3739
[project.optional-dependencies]
38-
dev = ["pytest", "black", "mypy", "coverage", "isort"]
40+
dev = [
41+
"pytest",
42+
"pytest-cov",
43+
"black",
44+
"mypy",
45+
"types-regex",
46+
"coverage",
47+
"isort",
48+
]
3949

4050
[project.scripts]
4151
pyobfuscate = "python_obfuscator.cli:cli"
@@ -47,7 +57,34 @@ line_length = 88
4757
[tool.pytest.ini_options]
4858
testpaths = ["tests"]
4959

60+
[tool.mypy]
61+
python_version = "3.10"
62+
packages = ["python_obfuscator"]
63+
explicit_package_bases = true
64+
warn_unused_ignores = true
65+
warn_return_any = true
66+
show_error_codes = true
67+
strict = false
68+
disallow_untyped_defs = false
69+
# TODO: Enable when more of the codebase is annotated:
70+
# check_untyped_defs = true
71+
ignore_missing_imports = false
72+
73+
[tool.pyright]
74+
pythonVersion = "3.10"
75+
include = ["python_obfuscator"]
76+
exclude = ["tests", "build", "dist", ".venv"]
77+
typeCheckingMode = "basic"
78+
reportMissingImports = true
79+
reportMissingTypeStubs = false
80+
5081
[tool.coverage.run]
5182
branch = true
5283
source = ["python_obfuscator"]
5384
omit = ["tests/*"]
85+
86+
[tool.coverage.report]
87+
show_missing = true
88+
skip_empty = true
89+
precision = 1
90+
fail_under = 95

0 commit comments

Comments
 (0)