Skip to content

Commit

Permalink
Use hatch test/fmt commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mdomke committed Jun 10, 2024
1 parent bd6527c commit 8e47808
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 47 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
run: pip install hatch
- name: Lint style
run: hatch run lint:style
run: hatch fmt --check

lint-typing:
runs-on: ubuntu-latest
Expand All @@ -41,10 +41,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install hatch
- name: Install hatch
uses: pypa/hatch@install
- name: Lint typing
run: hatch run lint:typing
run: hatch run types:check

test:
runs-on: ubuntu-latest
Expand All @@ -58,9 +58,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: pip install hatch
- name: Install hatch
uses: pypa/hatch@install
- name: Smoke test installation
run: pip install .
- name: Test
run: hatch run cov-test
run: hatch test --cover
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.4.7
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -9,6 +9,6 @@ repos:
hooks:
- id: doc8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.10.0
hooks:
- id: mypy
32 changes: 11 additions & 21 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
[envs.default]
[envs.hatch-test]
dependencies = [
"freezegun==1.4.*",
"pytest-cov==4.1.*",
"pytest==8.1.*",
]
features = [
"pydantic",
]

[envs.default.scripts]
cov-test = "pytest --cov=schwifty {args:tests schwifty}"
test = "cov-test --no-cov"
[envs.hatch-static-analysis]
config-path = ".ruff_defaults.toml"

[envs.lint]
[envs.types]
extra-dependencies = [
"ruff==0.3.*",
"mypy==1.9.*",
"doc8==1.1.*",
"pygments==2.16.*",
"mypy==1.10.*",
]
scripts = { check = "mypy --install-types --non-interactive {args:schwifty tests}" }

[envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:schwifty tests}"
style = [
"ruff format --check --diff {args:.}",
"ruff check {args:.}",
]
fmt = [
"ruff format {args:.}",
"ruff check --fix {args:.}",
[envs.docs]
extra-dependencies = [
"doc8==1.1.*",
"pygments==2.16.*",
]
docs = "doc8 docs/source"
scripts = { check = "doc8 docs/source" }

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ target-version = "py38"
line-length = 100

[tool.ruff.lint]
select = ["A", "B", "C", "C4", "E", "F", "I", "N", "PT", "Q", "RUF", "S", "SIM", "T10", "UP", "W", "YTT"]
fixable = ["RUF100", "I001"]
ignore = [
extend-select = ["A", "B", "C", "C4", "E", "F", "I", "N", "PT", "Q", "RUF", "S", "SIM", "T10", "UP", "W", "YTT"]
extend-fixable = ["RUF100", "I001"]
extend-ignore = [
"S101", # Allow usage of asserts
"A001", # Allow shadowing bultins
"A003", # Allow shadowing bultins on classes
Expand All @@ -90,7 +90,7 @@ order-by-type = false
[tool.coverage.run]
branch = true
parallel = true
source = ["ulid"]
source = ["schwifty"]

[tool.doc8]
max-line-length = 100
Expand Down
4 changes: 2 additions & 2 deletions schwifty/bban.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def bank_name(self) -> str | None:
"""str or None: The name of the bank associated with the IBAN bank code.
Examples:
>>> IBAN('DE89370400440532013000').bank_name
>>> IBAN("DE89370400440532013000").bank_name
'Commerzbank'
"""
return None if self.bank is None else self.bank["name"]
Expand All @@ -348,7 +348,7 @@ def bank_short_name(self) -> str | None:
"""str or None: The name of the bank associated with the IBAN bank code.
Examples:
>>> IBAN('DE89370400440532013000').bank_short_name
>>> IBAN("DE89370400440532013000").bank_short_name
'Commerzbank Köln'
"""
return None if self.bank is None else self.bank["short_name"]
Expand Down
16 changes: 8 additions & 8 deletions schwifty/bic.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ def from_bank_code(cls, country_code: str, bank_code: str) -> BIC:
"""Create a new BIC object from country-code and domestic bank-code.
Examples:
>>> bic = BIC.from_bank_code('DE', '20070000')
>>> bic = BIC.from_bank_code("DE", "20070000")
>>> bic.country_code
'DE'
>>> bic.bank_code
'DEUT'
>>> bic.location_code
'HH'
>>> BIC.from_bank_code('DE', '01010101')
>>> BIC.from_bank_code("DE", "01010101")
Traceback (most recent call last):
...
InvalidBankCode: Unknown bank code '01010101' for country 'DE'
Expand Down Expand Up @@ -344,7 +344,7 @@ def is_valid(self) -> bool:
to circumvent the implicit validation.
Examples:
>>> BIC('FOOBARBAZ', allow_invalid=True).is_valid
>>> BIC("FOOBARBAZ", allow_invalid=True).is_valid
False
.. versionadded:: 2020.08.1
Expand All @@ -359,7 +359,7 @@ def formatted(self) -> str:
"""str: The BIC separated in the blocks bank-, country- and location-code.
Examples:
>>> BIC('MARKDEF1100').formatted
>>> BIC("MARKDEF1100").formatted
'MARK DE F1 100'
"""
formatted = " ".join([self.bank_code, self.country_code, self.location_code])
Expand All @@ -378,7 +378,7 @@ def domestic_bank_codes(self) -> list[str]:
"""List[str]: The country specific bank-codes associated with the BIC.
Examples:
>>> BIC('MARKDEF1100').domestic_bank_codes
>>> BIC("MARKDEF1100").domestic_bank_codes
['10000000']
.. versionadded:: 2020.01.0
Expand All @@ -390,7 +390,7 @@ def bank_names(self) -> list[str]:
"""List[str]: The name of the banks associated with the BIC.
Examples:
>>> BIC('MARKDEF1100').bank_names
>>> BIC("MARKDEF1100").bank_names
['Bundesbank']
.. versionadded:: 2020.01.0
Expand All @@ -402,7 +402,7 @@ def bank_short_names(self) -> list[str]:
"""List[str]: The short name of the banks associated with the BIC.
Examples:
>>> BIC('MARKDEF1100').bank_short_names
>>> BIC("MARKDEF1100").bank_short_names
['BBk Berlin']
.. versionadded:: 2020.01.0
Expand Down Expand Up @@ -456,7 +456,7 @@ def type(self) -> str:
This can be one of 'testing', 'passive', 'reverse billing' or 'default'
Examples:
>>> BIC('MARKDEF1100').type
>>> BIC("MARKDEF1100").type
'passive'
Returns:
Expand Down
6 changes: 3 additions & 3 deletions schwifty/iban.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def is_valid(self) -> bool:
to circumvent the implicit validation.
Examples:
>>> IBAN('AB1234567890', allow_invalid=True).is_valid
>>> IBAN("AB1234567890", allow_invalid=True).is_valid
False
.. versionadded:: 2020.08.1
Expand Down Expand Up @@ -390,7 +390,7 @@ def bank_name(self) -> str | None:
"""str or None: The name of the bank associated with the IBAN bank code.
Examples:
>>> IBAN('DE89370400440532013000').bank_name
>>> IBAN("DE89370400440532013000").bank_name
'Commerzbank'
.. versionadded:: 2022.04.2
Expand All @@ -402,7 +402,7 @@ def bank_short_name(self) -> str | None:
"""str or None: The name of the bank associated with the IBAN bank code.
Examples:
>>> IBAN('DE89370400440532013000').bank_short_name
>>> IBAN("DE89370400440532013000").bank_short_name
'Commerzbank Köln'
.. versionadded:: 2022.04.2
Expand Down

0 comments on commit 8e47808

Please sign in to comment.