diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 1ef1beb..de016b1 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -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 @@ -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 @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 193ce88..1f90eeb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 diff --git a/hatch.toml b/hatch.toml index 880641b..da7e783 100644 --- a/hatch.toml +++ b/hatch.toml @@ -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" } diff --git a/pyproject.toml b/pyproject.toml index 0fb824e..aeaa078 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -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 diff --git a/schwifty/bban.py b/schwifty/bban.py index 5deb93d..1d46206 100644 --- a/schwifty/bban.py +++ b/schwifty/bban.py @@ -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"] @@ -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"] diff --git a/schwifty/bic.py b/schwifty/bic.py index e912060..245cec9 100644 --- a/schwifty/bic.py +++ b/schwifty/bic.py @@ -184,7 +184,7 @@ 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 @@ -192,7 +192,7 @@ def from_bank_code(cls, country_code: str, bank_code: str) -> BIC: >>> 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' @@ -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 @@ -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]) @@ -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 @@ -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 @@ -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 @@ -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: diff --git a/schwifty/iban.py b/schwifty/iban.py index cfc8b8c..fdb5afd 100644 --- a/schwifty/iban.py +++ b/schwifty/iban.py @@ -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 @@ -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 @@ -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