Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce Python type annotations in continuous integration #1202

Open
wants to merge 11 commits into
base: devel
Choose a base branch
from
24 changes: 22 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: "v5.0.0"
hooks:
- id: check-case-conflict
- id: check-merge-conflict
Expand All @@ -32,6 +32,26 @@ repos:
external/
)
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: "v1.7.1.15"
rev: "v1.7.7.23"
hooks:
- id: actionlint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.9.4"
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
# This needs to match the last version that still supports the minimum
# required Python version
rev: "v1.5.1"
hooks:
- id: mypy
additional_dependencies:
- blessings
- testtools
- types-Pygments
# Work around config file setting exclusion rules being bypassed when
# filenames are explicitly passed on the command line. See
# https://github.com/python/mypy/pull/12373#issuecomment-1071662559
# for the idea.
args: [.]
pass_filenames: false
43 changes: 41 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
cache_dir = "build/.mypy_cache"
explicit_package_bases = true
mypy_path = "$MYPY_CONFIG_FILE_DIR/src/sst/core/testingframework"
# This should be 3.6 but is not supported with the newest versions of mypy.
python_version = "3.8"
python_version = "3.6"

strict = true
warn_unused_ignores = true

exclude = [
'^scripts/',
Expand All @@ -20,3 +20,42 @@ module = [
"testtools.testsuite",
]
ignore_missing_imports = true

[tool.pyright]
pythonVersion = "3.6"

[tool.ruff]
cache-dir = "build/.ruff_cache"
line-length = 100
# This should be 3.6 but is not supported with the newest versions of ruff.
target-version = "py37"

[tool.ruff.lint]
ignore = [
"E401",
"E402",
"E701",
"E703",
"E713",
"E722",
"E731",
"F401",
"F403",
"F405",
"F523",
"F841",
]

[tool.ruff.lint.isort]
known-first-party = ["sst"]
lines-after-imports = 2
section-order = [
"future",
"standard-library",
"first-party",
"third-party",
"local-folder",
]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
4 changes: 2 additions & 2 deletions src/sst/core/testingframework/sst_unittest_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def testing_stat_output_diff(

### Built in LineFilters for filtering diffs
class LineFilter:
def __init__(self):
def __init__(self) -> None:
self.apply_to_ref_file = True
self.apply_to_out_file = True

Expand Down Expand Up @@ -1883,7 +1883,7 @@ def os_extract_tar(tarfilepath: str, targetdir: str = ".") -> bool:
try:
this_tar = tarfile.open(tarfilepath)
if sys.version_info.minor >= 12:
this_tar.extractall(targetdir, filter="data")
this_tar.extractall(targetdir, filter="data") # type: ignore [call-arg]
else:
this_tar.extractall(targetdir)
this_tar.close()
Expand Down
Loading
Loading