diff --git a/.codecov.yml b/.codecov.yml index f4462fc..428932a 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -2,7 +2,6 @@ # Validation check: # $ curl --data-binary @.codecov.yml https://codecov.io/validate - # https://docs.codecov.io/docs/codecovyml-reference codecov: bot: "codecov-io" @@ -13,7 +12,7 @@ codecov: wait_for_ci: yes coverage: - precision: 0 # 2 = xx.xx%, 0 = xx% + precision: 0 # 2 = xx.xx%, 0 = xx% round: nearest # how coverage is rounded: down/up/nearest range: 40...100 # custom range of coverage colors from red -> yellow -> green status: @@ -32,7 +31,7 @@ coverage: # https://docs.codecov.com/docs/github-checks#disabling-github-checks-patch-annotations github_checks: - annotations: false + annotations: false parsers: gcov: @@ -47,5 +46,5 @@ parsers: comment: layout: header, diff require_changes: true - behavior: default # update if exists else create new + behavior: default # update if exists else create new # branches: * diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 579fe07..0000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,2 +0,0 @@ -documentation: - - docs/**/* diff --git a/.github/mergify.yml b/.github/mergify.yml index 673a5ad..7cfbc57 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -1,33 +1,32 @@ pull_request_rules: - - name: warn on conflicts conditions: - conflict - - -draft # filter-out GH draft PRs + - -draft # filter-out GH draft PRs - -label="has conflicts" actions: # comment: # message: This pull request is now in conflict... :( label: - add: [ "has conflicts" ] + add: ["has conflicts"] - name: resolved conflicts conditions: - -conflict - label="has conflicts" - - -draft # filter-out GH draft PRs - - -merged # not merged yet + - -draft # filter-out GH draft PRs + - -merged # not merged yet - -closed actions: label: - remove: [ "has conflicts" ] + remove: ["has conflicts"] - name: update PR conditions: - -conflict - - -draft # filter-out GH draft PRs + - -draft # filter-out GH draft PRs #- base=main # apply only on master - - -title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) + - -title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) - "#approved-reviews-by>=1" # number of review approvals actions: update: {} @@ -35,34 +34,34 @@ pull_request_rules: - name: Ready to Go conditions: - -conflict - - -draft # filter-out GH draft PRs - - -title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) - - "#approved-reviews-by>=1" # number of review approvals - - "#changes-requested-reviews-by=0" # no requested changes + - -draft # filter-out GH draft PRs + - -title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) + - "#approved-reviews-by>=1" # number of review approvals + - "#changes-requested-reviews-by=0" # no requested changes - "#check-pending<=1" - "#check-failure<2" actions: label: - add: [ "0:] Ready-To-Go" ] + add: ["0:] Ready-To-Go"] - name: Not ready yet conditions: - or: - - draft # filter-out GH draft PRs - - title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) - - "#approved-reviews-by=0" # number of review approvals - - "#changes-requested-reviews-by>=1" # no requested changes - - "#check-failure>=3" + - draft # filter-out GH draft PRs + - title~=(?i)wip # skip all PR that title contains “WIP” (ignoring case) + - "#approved-reviews-by=0" # number of review approvals + - "#changes-requested-reviews-by>=1" # no requested changes + - "#check-failure>=3" actions: label: - remove: [ "0:] Ready-To-Go" ] + remove: ["0:] Ready-To-Go"] - name: add reviewer conditions: - - -conflict # skip if conflict - - -draft # filter-out GH draft PRs - - "#approved-reviews-by<1" # number of review approvals - - "#review-requested<1" # number of requested reviews + - -conflict # skip if conflict + - -draft # filter-out GH draft PRs + - "#approved-reviews-by<1" # number of review approvals + - "#review-requested<1" # number of requested reviews actions: request_reviews: users: diff --git a/.github/workflows/ci_pkg-install.yml b/.github/workflows/ci_pkg-install.yml index 43c1358..6840ec6 100644 --- a/.github/workflows/ci_pkg-install.yml +++ b/.github/workflows/ci_pkg-install.yml @@ -1,7 +1,7 @@ name: Install package # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows -on: # Trigger the workflow on push or pull request, but only for the main branch +on: # Trigger the workflow on push or pull request, but only for the main branch push: branches: [main] pull_request: {} @@ -18,65 +18,64 @@ jobs: pkg-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.8 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.8" - - name: Check package - run: | - pip install check-manifest - check-manifest - python setup.py check --metadata --strict + - name: Check package + run: | + pip install check-manifest + check-manifest + python setup.py check --metadata --strict - - name: Create package - run: | - pip install --upgrade setuptools wheel - python setup.py sdist bdist_wheel + - name: Create package + run: | + pip install --upgrade setuptools wheel + python setup.py sdist bdist_wheel - - name: Verify package - run: | - pip install -q -r tests/requirements.txt - twine check dist/* - python setup.py clean + - name: Verify package + run: | + pip install -q -r tests/requirements.txt + twine check dist/* + python setup.py clean pkg-install: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - python-version: [3.8] #, 3.9 + os: ["ubuntu-latest", "macOS-latest", "windows-latest"] + python-version: ["3.8"] #, 3.9 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - - name: Create package - run: | - pip install setuptools wheel - python setup.py sdist bdist_wheel - - - name: Try installing - working-directory: dist - run: | - ls -lh - pip install $(python -c "import glob ; print(' '.join(glob.glob('*.whl')))") - pip show kaggle-sandbox - python -c "import challenge_xyz ; print(challenge_xyz.__version__)" + - name: Create package + run: | + pip install setuptools wheel + python setup.py sdist bdist_wheel + - name: Try installing + working-directory: dist + run: | + ls -lh + pip install $(python -c "import glob ; print(' '.join(glob.glob('*.whl')))") + pip show kaggle-sandbox + python -c "import challenge_xyz ; print(challenge_xyz.__version__)" watcher: runs-on: ubuntu-latest needs: ["pkg-install", "pkg-check"] if: always() steps: - - run: echo "${{ needs.pkg-install.result }}" - - name: failing... - if: needs.pkg-install.result == 'failure' - run: exit 1 - - name: cancelled or skipped... - if: contains(fromJSON('["cancelled", "skipped"]'), needs.pkg-install.result) - timeout-minutes: 1 - run: sleep 90 + - run: echo "${{ needs.pkg-install.result }}" + - name: failing... + if: needs.pkg-install.result == 'failure' + run: exit 1 + - name: cancelled or skipped... + if: contains(fromJSON('["cancelled", "skipped"]'), needs.pkg-install.result) + timeout-minutes: 1 + run: sleep 90 diff --git a/.github/workflows/ci_schema.yml b/.github/workflows/ci_schema.yml index 30bd2ab..9c36900 100644 --- a/.github/workflows/ci_schema.yml +++ b/.github/workflows/ci_schema.yml @@ -12,25 +12,25 @@ jobs: validate-schema: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Install pkg - run: pip install check-jsonschema + - name: Install pkg + run: pip install check-jsonschema - - name: Scan repo - id: folders - run: python -c "import os; print('gh_actions=' + str(int(os.path.isdir('.github/actions'))))" >> $GITHUB_OUTPUT + - name: Scan repo + id: folders + run: python -c "import os; print('gh_actions=' + str(int(os.path.isdir('.github/actions'))))" >> $GITHUB_OUTPUT - # https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json - - name: GitHub Actions - workflow - run: | - files=$(find .github/workflows -name '*.yml' -or -name '*.yaml' -not -name '__*') - check-jsonschema -v $files --builtin-schema "github-workflows" + # https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json + - name: GitHub Actions - workflow + run: | + files=$(find .github/workflows -name '*.yml' -or -name '*.yaml' -not -name '__*') + check-jsonschema -v $files --builtin-schema "github-workflows" - # https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json - - name: GitHub Actions - action - if: steps.folders.outputs.gh_actions == '1' - run: | - files=$(find .github/actions -name '*.yml' -or -name '*.yaml') - heck-jsonschema -v $files --builtin-schema "github-actions" + # https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json + - name: GitHub Actions - action + if: steps.folders.outputs.gh_actions == '1' + run: | + files=$(find .github/actions -name '*.yml' -or -name '*.yaml') + heck-jsonschema -v $files --builtin-schema "github-actions" diff --git a/.github/workflows/ci_testing.yml b/.github/workflows/ci_testing.yml index fb00fe0..f9bf7b2 100644 --- a/.github/workflows/ci_testing.yml +++ b/.github/workflows/ci_testing.yml @@ -1,7 +1,7 @@ name: CI complete testing # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows -on: # Trigger the workflow on push or pull request, but only for the main branch +on: # Trigger the workflow on push or pull request, but only for the main branch push: branches: [main] pull_request: {} @@ -22,75 +22,61 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] python-version: [3.8] - requires: ['oldest', 'latest'] + requires: ["oldest", "latest"] # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 25 steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" - - name: Set min. dependencies - if: matrix.requires == 'oldest' - run: | - for fpath in ('requirements.txt', 'tests/requirements.txt'): - req = open(fpath).read().replace('>=', '==') - open(fpath, 'w').write(req) - shell: python + - name: Set min. dependencies + if: matrix.requires == 'oldest' + run: | + for fpath in ('requirements.txt', 'tests/requirements.txt'): + req = open(fpath).read().replace('>=', '==') + open(fpath, 'w').write(req) + shell: python - # Note: This uses an internal pip API and may not always work - # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow - - name: Get pip cache - id: pip-cache - run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + - name: Install dependencies + run: | + pip install -e . -U -r tests/requirements.txt \ + --find-links https://download.pytorch.org/whl/cpu/torch_stable.html + pip list - - name: Cache pip - uses: actions/cache@v4 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: ${{ runner.os }}-${{ matrix.python-version }}-pip- + - name: Tests + run: python -m pytest . -v --cov=challenge_xyz - - name: Install dependencies - run: | - pip install -e . -U -r tests/requirements.txt \ - --find-links https://download.pytorch.org/whl/cpu/torch_stable.html - pip list - - - name: Tests - run: python -m pytest . -v --cov=challenge_xyz - - - name: Statistics - if: success() - run: | - coverage report - coverage xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - if: always() - # see: https://github.com/actions/toolkit/issues/399 - continue-on-error: true - with: - file: coverage.xml - flags: cpu,pytest,python${{ matrix.python-version }} - fail_ci_if_error: false + - name: Statistics + run: | + coverage report + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + if: always() + # see: https://github.com/actions/toolkit/issues/399 + continue-on-error: true + with: + file: coverage.xml + flags: cpu,pytest,python${{ matrix.python-version }} + fail_ci_if_error: false guardian: runs-on: ubuntu-latest needs: pytester if: always() steps: - - run: echo "${{ needs.pytester.result }}" - - name: failing... - if: needs.pytester.result == 'failure' - run: exit 1 - - name: cancelled or skipped... - if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result) - timeout-minutes: 1 - run: sleep 90 + - run: echo "${{ needs.pytester.result }}" + - name: failing... + if: needs.pytester.result == 'failure' + run: exit 1 + - name: cancelled or skipped... + if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result) + timeout-minutes: 1 + run: sleep 90 diff --git a/.github/workflows/cleanup-caches.yml b/.github/workflows/cleanup-caches.yml index 77ad7c6..0c60c5a 100644 --- a/.github/workflows/cleanup-caches.yml +++ b/.github/workflows/cleanup-caches.yml @@ -5,7 +5,6 @@ on: types: [closed] jobs: - pr-cleanup: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/code-format.yml b/.github/workflows/code-format.yml index 4f83102..8e93368 100644 --- a/.github/workflows/code-format.yml +++ b/.github/workflows/code-format.yml @@ -1,7 +1,7 @@ name: Code formatting # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows -on: # Trigger the workflow on push or pull request, but only for the main branch +on: # Trigger the workflow on push or pull request, but only for the main branch push: branches: [main] pull_request: {} @@ -11,7 +11,6 @@ defaults: shell: bash jobs: - pre-commit-check: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 195d2d8..718bc7a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,9 +2,9 @@ name: "CodeQL" on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] schedule: - cron: "1 18 * * 3" @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ python ] + language: [python] steps: - name: Checkout diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 0b4be67..a4d5d27 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,14 +1,14 @@ name: Greetings # https://github.com/marketplace/actions/first-interaction -on: [issues] # pull_request +on: [issues] # pull_request jobs: greeting: runs-on: ubuntu-latest steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: 'Hi! thanks for your contribution!, great first issue!' - pr-message: 'Hey thanks for the input! Please give us a bit of time to review it!' + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: "Hi! thanks for your contribution!, great first issue!" + pr-message: "Hey thanks for the input! Please give us a bit of time to review it!" diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 293c513..b426bd6 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,7 +1,7 @@ name: PyPI Release # https://help.github.com/en/actions/reference/events-that-trigger-workflows -on: # Trigger the workflow on push or pull request, but only for the main branch +on: # Trigger the workflow on push or pull request, but only for the main branch push: branches: [main] release: @@ -14,28 +14,28 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.8 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.8 - - name: Install dependencies - run: python -m pip install --user --upgrade setuptools wheel - - name: Build - run: python setup.py sdist bdist_wheel + - name: Install dependencies + run: python -m pip install --user --upgrade setuptools wheel + - name: Build + run: python setup.py sdist bdist_wheel - # We do this, since failures on test.pypi aren't that bad - - name: Publish to Test PyPI - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.test_pypi_password }} - repository_url: https://test.pypi.org/legacy/ + # We do this, since failures on test.pypi aren't that bad + - name: Publish to Test PyPI + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.test_pypi_password }} + repository_url: https://test.pypi.org/legacy/ - - name: Publish distribution 📦 to PyPI - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} + - name: Publish distribution 📦 to PyPI + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c2db2e4..ccdaa4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: ci: autofix_prs: true - autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' + autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions" autoupdate_schedule: quarterly # submodules: true @@ -19,54 +19,49 @@ repos: - id: check-toml - id: check-added-large-files exclude: .*\.ipynb - args: ['--maxkb=250', '--enforce-all'] + args: ["--maxkb=250", "--enforce-all"] - id: check-docstring-first - id: detect-private-key - - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 hooks: - - id: pyupgrade - args: [--py38-plus] - name: Upgrade code - - - repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 - hooks: - - id: docformatter - args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120] - - - repo: https://github.com/omnilib/ufmt - rev: v2.7.0 - hooks: - - id: ufmt - additional_dependencies: - - black == 22.3.0 - - usort == 1.0.2 + - id: codespell + additional_dependencies: [tomli] + args: ["--write-changes"] + exclude: pyproject.toml - repo: https://github.com/executablebooks/mdformat rev: 0.7.17 hooks: - id: mdformat + args: ["--number"] additional_dependencies: - mdformat-gfm - mdformat-black - mdformat_frontmatter - - repo: https://github.com/asottile/yesqa - rev: v1.5.0 - hooks: - - id: yesqa - additional_dependencies: - - pep8-naming - - pydocstyle - #- flake8-comprehensions - #- flake8-pytest-style - #- flake8-return - #- flake8-simplify - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.5.0 hooks: - id: ruff args: ["--fix"] + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + files: \.(json|yml|yaml|toml) + # https://prettier.io/docs/en/options.html#print-width + args: ["--print-width=120"] + + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 2.1.3 + hooks: + - id: pyproject-fmt + additional_dependencies: [tox] + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.18 + hooks: + - id: validate-pyproject diff --git a/pyproject.toml b/pyproject.toml index bfed1a8..b3e15da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,95 +1,97 @@ -[metadata] -license_file = "LICENSE" -description-file = "README.md" - [build-system] requires = [ - "setuptools", - "wheel", + "setuptools", + "wheel", ] -[tool.black] -# https://github.com/psf/black +[tool.ruff] +target-version = "py38" line-length = 120 -exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)" -[tool.usort] -known_first_party = [ - "challenge_xyz", +#[tool.ruff.pycodestyle] +#ignore-overlong-task-comments = true +format.preview = true +lint.select = [ + "D", # see: https://pypi.org/project/pydocstyle + "E", + "F", # see: https://pypi.org/project/pyflakes + "I", #see: https://pypi.org/project/isort/ + "N", # see: https://pypi.org/project/pep8-naming + "S", # see: https://pypi.org/project/flake8-bandit + "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up + "W", # see: https://pypi.org/project/pycodestyle +] +lint.extend-select = [ + "A", # see: https://pypi.org/project/flake8-builtins + "ANN", # see: https://pypi.org/project/flake8-annotations + "B", # see: https://pypi.org/project/flake8-bugbear + "C4", # see: https://pypi.org/project/flake8-comprehensions + "EXE", # see: https://pypi.org/project/flake8-executable + "ISC", # see: https://pypi.org/project/flake8-implicit-str-concat + "PERF", # see: https://pypi.org/project/perflint/ + "PIE", # see: https://pypi.org/project/flake8-pie + "PLE", # see: https://pypi.org/project/pylint/ + "PT", # see: https://pypi.org/project/flake8-pytest-style + "PYI", # see: https://pypi.org/project/flake8-pyi/ + "Q", # see: https://pypi.org/project/flake8-quotes + "RET", # see: https://pypi.org/project/flake8-return + "RUF", # Ruff-specific rules + "SIM", # see: https://pypi.org/project/flake8-simplify + "T10", # see: https://pypi.org/project/flake8-debugger + "TID", # see: https://pypi.org/project/flake8-tidy-imports/ + "YTT", # see: https://pypi.org/project/flake8-2020 +] +lint.ignore = [ + "ANN101", # Missing type annotation for `self` in method + "D100", # todo: Missing docstring in public module + "D104", # todo: Missing docstring in public package + "D107", # Missing docstring in `__init__` + "E731", # Do not assign a lambda expression, use a def + "EXE002", # The file is executable but no shebang is present + "ISC001", # potehtional comflict, flagged by Ruff itsel +] +lint.unfixable = [ + "F401", ] -skip_glob = [] -profile = "black" -line_length = 120 +# Unlike Flake8, default to a complexity level of 10. +lint.mccabe.max-complexity = 10 +# Use Google-style docstrings. +lint.pydocstyle.convention = "google" + +[tool.codespell] +#skip = '*.py' +quiet-level = 3 +# Todo: comma separated list of words; waiting for: +# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603 +# Todo: also adding links until they ignored by its: nature +# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960 +#ignore-words-list = """ +# wil, \ +# archiv +#""" [tool.pytest.ini_options] norecursedirs = [ - ".git", - ".github", - "dist", - "build", - "docs", + ".git", + ".github", + "dist", + "build", + "docs", ] addopts = [ - "--strict-markers", - "--doctest-modules", - "--color=yes", - "--disable-pytest-warnings", + "--strict-markers", + "--doctest-modules", + "--color=yes", + "--disable-pytest-warnings", ] filterwarnings = [ - "error::FutureWarning", + "error::FutureWarning", ] xfail_strict = true junit_duration_report = "call" [tool.coverage.report] exclude_lines = [ - "pragma: no cover", - "pass", + "pragma: no cover", + "pass", ] - -[tool.ruff] -line-length = 120 -# Enable Pyflakes `E` and `F` codes by default. -select = [ - "E", "W", # see: https://pypi.org/project/pycodestyle - "F", # see: https://pypi.org/project/pyflakes - "D", # see: https://pypi.org/project/pydocstyle - "N", # see: https://pypi.org/project/pep8-naming -] -extend-select = [ - "C4", # see: https://pypi.org/project/flake8-comprehensions - "PT", # see: https://pypi.org/project/flake8-pytest-style - "RET", # see: https://pypi.org/project/flake8-return - "SIM", # see: https://pypi.org/project/flake8-simplify -] -ignore = [ - "E731", # Do not assign a lambda expression, use a def -] -# Exclude a variety of commonly ignored directories. -exclude = [ - ".eggs", - ".git", - ".ruff_cache", - "__pypackages__", - "_build", - "build", - "dist", - "docs" -] -ignore-init-module-imports = true - -[tool.ruff.per-file-ignores] -"setup.py" = ["D100", "RET504"] -"__about__.py" = ["D100"] -"__init__.py" = ["D100"] - -[tool.ruff.pydocstyle] -# Use Google-style docstrings. -convention = "google" - -#[tool.ruff.pycodestyle] -#ignore-overlong-task-comments = true - -[tool.ruff.mccabe] -# Unlike Flake8, default to a complexity level of 10. -max-complexity = 10 diff --git a/setup.py b/setup.py index d05252e..5922710 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ _PATH_SOURCE = os.path.join(_PATH_ROOT, "src") -def _load_py_module(fname, pkg="challenge_xyz"): +def _load_py_module(fname: str, pkg: str = "challenge_xyz"): # noqa: ANN202 spec = spec_from_file_location(os.path.join(pkg, fname), os.path.join(_PATH_SOURCE, pkg, fname)) py = module_from_spec(spec) spec.loader.exec_module(py) @@ -24,12 +24,11 @@ def _load_py_module(fname, pkg="challenge_xyz"): _about = _load_py_module("__about__.py") -def _load_requirements(path_dir=_PATH_ROOT, comment_char="#") -> list: +def _load_requirements(path_dir: str = _PATH_ROOT, comment_char: str = "#") -> list: with open(os.path.join(path_dir, "requirements.txt")) as file: lines = [ln.strip() for ln in file.readlines()] reqs = [ln[: ln.index(comment_char)] if comment_char in ln else ln for ln in lines] - reqs = [ln for ln in reqs if ln and not any(s in ln for s in ["http://", "https://"])] - return reqs + return [ln for ln in reqs if ln and not any(s in ln for s in ["http://", "https://"])] def _load_long_description(homepage: str, version: str) -> str: @@ -39,8 +38,7 @@ def _load_long_description(homepage: str, version: str) -> str: # replace relative repository path to absolute link to the release text = text.replace("](docs", f"]({url}") # SVG images are not readable on PyPI, so replace them with PNG - text = text.replace(".svg", ".png") - return text + return text.replace(".svg", ".png") # https://packaging.python.org/discussions/install-requires-vs-requirements / diff --git a/src/challenge_xyz/__init__.py b/src/challenge_xyz/__init__.py index b6d8828..79654a7 100644 --- a/src/challenge_xyz/__init__.py +++ b/src/challenge_xyz/__init__.py @@ -2,7 +2,7 @@ import os -from challenge_xyz.__about__ import * # noqa: F401, F403 +from challenge_xyz.__about__ import * # noqa: F403 _PATH_PACKAGE = os.path.realpath(os.path.dirname(__file__)) _PATH_PROJECT = os.path.dirname(_PATH_PACKAGE)