diff --git a/nhs_number/generate.py b/nhs_number/generate.py index a919ea9..572bd6e 100644 --- a/nhs_number/generate.py +++ b/nhs_number/generate.py @@ -23,7 +23,6 @@ def generate( for_region: Region = None, quantity: int = 1, ) -> list: - """ Generates valid or invalid NHS numbers, for testing. diff --git a/nhs_number/standardise.py b/nhs_number/standardise.py index fba12f6..dbcd6ab 100644 --- a/nhs_number/standardise.py +++ b/nhs_number/standardise.py @@ -10,7 +10,9 @@ * Marcus Baw """ # standard imports -from __future__ import annotations # for Python 3.7 (remove once we stop supporting 3.7) +from __future__ import ( + annotations, +) # for Python 3.7 (remove once we stop supporting 3.7) import re import warnings @@ -51,6 +53,11 @@ def standardise_format(nhs_number: str | int) -> str: def normalise_number(nhs_number: str) -> str: - warnings.warn("The normalise_number() function is deprecated - use " - "standardise_format() instead", DeprecationWarning) + warnings.warn( + ( + "The normalise_number() function is deprecated - use " + "standardise_format() instead" + ), + DeprecationWarning, + ) return standardise_format(nhs_number) diff --git a/nhs_number/validate.py b/nhs_number/validate.py index f5089d2..a0021bc 100644 --- a/nhs_number/validate.py +++ b/nhs_number/validate.py @@ -9,7 +9,9 @@ * Andy Law * Marcus Baw """ -from __future__ import annotations # for Python 3.7 (remove once we stop supporting 3.7) +from __future__ import ( + annotations, +) # for Python 3.7 (remove once we stop supporting 3.7) from nhs_number.standardise import standardise_format from nhs_number.constants import Region diff --git a/pyproject.toml b/pyproject.toml index fe6dc65..9dc0247 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,11 +38,13 @@ python = "^3.7" pytest = "^7.3.1" black = "^23.3.0" mkdocs-material = "^9.1.15" +tox = "^4.8.0" [tool.poetry.urls] "Issue Tracker" = "https://github.com/uk-fci/nhs-number/issues" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/tests/context.py b/tests/context.py index e4d94cf..7973942 100644 --- a/tests/context.py +++ b/tests/context.py @@ -1,6 +1,8 @@ import os import sys -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +) import nhs_number diff --git a/tests/test_bulk_validation.py b/tests/test_bulk_validation.py index aab20fd..079e011 100644 --- a/tests/test_bulk_validation.py +++ b/tests/test_bulk_validation.py @@ -17,10 +17,14 @@ @pytest.mark.skipif( - not os.path.exists("local-test-data/testdata-909090-valid-nhs-numbers.csv"), - reason="This test requires a large list of valid NHS numbers which we do" - " not want to include in the repo by default for reasons of file" - " size", + not os.path.exists( + "local-test-data/testdata-909090-valid-nhs-numbers.csv" + ), + reason=( + "This test requires a large list of valid NHS numbers which we do" + " not want to include in the repo by default for reasons of file" + " size" + ), ) def test_with_large_numbers_of_known_valid_nhs_numbers(): with open( diff --git a/tests/test_details.py b/tests/test_details.py index 01860d7..48b51c2 100644 --- a/tests/test_details.py +++ b/tests/test_details.py @@ -12,5 +12,7 @@ def test_valid_synthetic_nhs_number_details(): assert number.calculated_checksum == 0 assert isinstance(number.region, Region) assert "test" in number.region.tags - assert number.region_comment == ("Not to be issued " - "(Synthetic/test patients PDS)") + assert ( + number.region_comment + == "Not to be issued (Synthetic/test patients PDS)" + ) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..d594819 --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +[tox] +isolated_build = true +envlist = black, py{37,38,39,310,311} + +[testenv] +allowlist_externals = poetry +commands = + poetry install -v + poetry run pytest --ignore=tests/test_bulk_validation.py + +[testenv:black] +description = 'Check code format with Black' +commands = poetry run black --check . +