From 5eca2a62def0e1cd69641963625409cd9cd5a8a8 Mon Sep 17 00:00:00 2001 From: Shane <30691680+gamesguru@users.noreply.github.com> Date: Tue, 9 Sep 2025 12:10:28 -0400 Subject: [PATCH] add lint stuff lint configs --- .github/workflows/test.yml | 43 +++++++++++++++++++++ .gitignore | 4 +- .pylintrc | 17 +++++++++ .requirements-lint.txt | 5 +++ Makefile | 7 ++++ setup.cfg | 78 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 .pylintrc create mode 100644 .requirements-lint.txt create mode 100644 Makefile create mode 100644 setup.cfg diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..830059a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +--- +name: lint + +"on": + push: {} + +permissions: + contents: read + +jobs: + lint: + runs-on: [ubuntu-latest] + + env: + SKIP_VENV: 1 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Fetch master (for incremental diff, lint filter mask) + run: git fetch origin master + + - name: Reload Cache / pip + uses: actions/setup-python@v5 + with: + python-version: 3 + cache: "pip" # caching pip dependencies + cache-dependency-path: "**/*requirements*.txt" + update-environment: false + + - name: Install requirements + run: | + pip install -r requirements.txt + pip install -r .requirements-lint.txt + + # NOTE: pytest is needed to lint the folder: "tests/" + # pip install -r requirements-test.txt + + - name: Lint + run: make lint diff --git a/.gitignore b/.gitignore index 0679b96..900678e 100644 --- a/.gitignore +++ b/.gitignore @@ -134,7 +134,7 @@ dmypy.json dump.rdb # Dotfiles -.* +/.idea !.gitignore !.readthedocs.yml @@ -144,4 +144,4 @@ dump.rdb # getmyancestors stuff *.log *.settings -*.ged \ No newline at end of file +*.ged diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..1990f74 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,17 @@ +[MASTER] + +fail-under=9.5 + + +[MESSAGES CONTROL] + +disable= + fixme, + consider-using-f-string, + missing-module-docstring, + missing-function-docstring, + too-many-arguments, + too-many-positional-arguments, + too-many-instance-attributes, + too-many-branches, + too-many-statements, diff --git a/.requirements-lint.txt b/.requirements-lint.txt new file mode 100644 index 0000000..47fc2b7 --- /dev/null +++ b/.requirements-lint.txt @@ -0,0 +1,5 @@ +flake8==7.3.0 +isort==6.0.1 +mypy==1.171 +pylint==3.3.8 +black==25.1.0 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d167625 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +LINT_LOCS ?= getmyancestors/ + +.PHONY: lint +lint: + black $(LINT_LOCS) + isort $(LINT_LOCS) + flake8 $(LINT_LOCS) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2556747 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,78 @@ +[tool:pytest] +# See: https://docs.pytest.org/en/7.1.x/reference/customize.html +testpaths = + tests + +[coverage:run] +# See: https://coverage.readthedocs.io/en/7.2.2/config.html#run +command_line = -m pytest +source = ntclient + +[coverage:report] +fail_under = 90.00 +precision = 2 + +show_missing = True +skip_empty = True +skip_covered = True + +omit = + # Unlike the server & db, the CLI doesn't call the sql module. + # It directly imports the `build_ntsqlite()` function. + ntclient/ntsqlite/sql/__main__.py, + +exclude_lines = + pragma: no cover + + + +[pycodestyle] +max-line-length = 88 + + + +[flake8] +per-file-ignores = + # Allow unused imports in __init__.py files + ; __init__.py:F401, + +max-line-length = 88 + +ignore = + # line break before binary operator + W503, + + + +[isort] +line_length = 88 +known_first_party = ntclient + +# See: https://copdips.com/2020/04/making-isort-compatible-with-black.html +multi_line_output = 3 +include_trailing_comma = True + + + +[mypy] +show_error_codes = True +;show_error_context = True +;pretty = True + +disallow_incomplete_defs = True +disallow_untyped_defs = True +disallow_untyped_calls = True +disallow_untyped_decorators = True + +;strict_optional = True +no_implicit_optional = True + +warn_return_any = True +warn_redundant_casts = True +warn_unreachable = True + +warn_unused_ignores = True +warn_unused_configs = True +warn_incomplete_stub = True + +# Our tests, they don't return a value typically -- 2.52.0