Skip to content

Commit

Permalink
style: add hatch static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
hartungstenio committed May 3, 2024
1 parent 4cdf54d commit 13af6ad
Show file tree
Hide file tree
Showing 30 changed files with 712 additions and 193 deletions.
47 changes: 11 additions & 36 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,27 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: lint
tests:
name: Run tests on ${{ matrix.python-version }}
runs-on: ubuntu-latest
env:
HATCH_ENV: lint
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Hatch
run: pipx install hatch

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Run linters
run: |
hatch env run lint
- name: Check dead fixtures
run: |
hatch env run check-fixtures
test:
name: Run tests
runs-on: ubuntu-latest
env:
HATCH_ENV: test
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Hatch
run: pipx install hatch
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup Hatch
run: pipx install hatch

- name: Run static analysis
run: hatch fmt --check

- name: Run tests
run: |
hatch env run -i py=${{ matrix.python-version }} test
hatch env run -e tests -i py=${{ matrix.python-version }} test
5 changes: 2 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
#
# # noqa: INP001
# Loafer documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 12 03:26:33 2016.
#
Expand Down Expand Up @@ -45,7 +44,7 @@

# General information about the project.
project = "Loafer"
copyright = "2016-2019, George Y. Kussumoto"
copyright = "2016-2019, George Y. Kussumoto" # noqa: A001
author = "George Y. Kussumoto"

# The version info for the project you're documenting, acts as replacement for
Expand Down
2 changes: 1 addition & 1 deletion docs/source/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ A description of all the exceptions:
* ``DeleteMessage``: if any :doc:`handlers` raises this exception, the message will
be rejected and acknowledged (the message will be deleted).

* ``LoaferException``: the base exception for ``DeleteMessage``.
* ``LoaferError``: the base exception for ``DeleteMessage``.
21 changes: 0 additions & 21 deletions hatch.toml

This file was deleted.

39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,45 @@ packages = ["src/loafer"]
[tool.hatch.version]
source = "vcs"

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"pytest-asyncio",
"pytest-deadfixtures",
]

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
]
cov = [
"test-cov",
"cov-report",
]

[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.types]
dependencies = [
"mypy>=1.0.0",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/loafer tests}"

[tool.hatch.envs.hatch-static-analysis]
config-path = "ruff_defaults.toml"

[tool.pytest.ini_options]
testpaths = ["tests"]
asyncio_mode = "strict"

[tool.ruff]
extend = "ruff_defaults.toml"

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"
Loading

0 comments on commit 13af6ad

Please sign in to comment.