diff --git a/README.rst b/README.rst index 1fccf88..743e4be 100644 --- a/README.rst +++ b/README.rst @@ -39,6 +39,12 @@ Static linting: poetry run pylint earthsnake tests +Code style check: + +.. code-block:: sh + + poetry run black --diff --skip-string-normalization earthsnake tests + Tests: .. code-block:: sh diff --git a/earthsnake/base32.py b/earthsnake/base32.py index a8c688b..05b19e2 100644 --- a/earthsnake/base32.py +++ b/earthsnake/base32.py @@ -29,9 +29,7 @@ def base32_string_to_bytes(string: str) -> bytes: """ if not string.startswith("b"): - raise ValueError( - f"can't decode base32 string - it should start with a 'b'. {str}" - ) + raise ValueError(f"can't decode base32 string - it should start with a 'b'. {str}") string = string[1:] @@ -44,9 +42,7 @@ def base32_string_to_bytes(string: str) -> bytes: # make sure no padding characters are on the end if string.endswith("="): - raise ValueError( - "can't decode base32 string - it contains padding characters ('=')" - ) + raise ValueError("can't decode base32 string - it contains padding characters ('=')") pad_length = 8 - len(string) % 8 string += '=' * pad_length diff --git a/earthsnake/exc.py b/earthsnake/exc.py index 1168f0c..0c88cc3 100644 --- a/earthsnake/exc.py +++ b/earthsnake/exc.py @@ -1,6 +1,7 @@ """Exception types for Earthsnake """ + class EarthsnakeError(Exception): """Basic Earthsnake error @@ -9,5 +10,4 @@ class EarthsnakeError(Exception): class ValidationError(EarthsnakeError): - """Raised when something doesn’t pass as a valid Earthsnake object - """ + """Raised when something doesn’t pass as a valid Earthsnake object""" diff --git a/pyproject.toml b/pyproject.toml index db5a25f..120c6c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,10 @@ black = "^22.3.0" mypy = "^0.942" pytest-cov = "^3.0.0" +[tool.black] +skip-string-normalization = true +line-length = 100 + [tool.pytest.ini_options] markers = [ "id_key_seed: seed to create an identity secret from", diff --git a/tests/test_identity.py b/tests/test_identity.py index 95af054..c9efe90 100644 --- a/tests/test_identity.py +++ b/tests/test_identity.py @@ -65,9 +65,7 @@ def test_init_no_keys() -> None: def test_str(identity: Identity) -> None: """Test if the __str__ method returns the author address""" - assert ( - str(identity) == '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + assert str(identity) == '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' @pytest.mark.id_key_seed(TEST_SEED) @@ -85,9 +83,7 @@ def test_from_address() -> None: skey = SigningKey(TEST_SEED) vkey = skey.get_verifying_key() - identity = Identity.from_address( - '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + identity = Identity.from_address('@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya') assert identity.name == 'test' assert identity.sign_key is None @@ -112,9 +108,7 @@ def test_generate(mocker: MockerFixture) -> None: mocker.patch('earthsnake.identity.create_keypair', return_value=(skey, vkey)) identity = Identity.generate('test') - assert ( - str(identity) == '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + assert str(identity) == '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' assert identity.sign_key assert identity.verify_key assert identity.name == 'test' @@ -131,9 +125,7 @@ def test_mnemonic(identity: Identity) -> None: def test_mnemonic_no_signing_key() -> None: """Test if the mnemonic property returns None if there is no signing key""" - identity = Identity.from_address( - '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + identity = Identity.from_address('@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya') assert identity.mnemonic is None @@ -147,18 +139,13 @@ def test_from_mnemonic() -> None: assert identity.name == name assert identity.sign_key assert identity.sign_key.to_seed() == TEST_SEED - assert ( - str(identity) - == f'@{name}.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + assert str(identity) == f'@{name}.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' @pytest.mark.parametrize( 'address', [ - pytest.param( - 'noat.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya', id='no_at' - ), + pytest.param('noat.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya', id='no_at'), pytest.param( '@toolong.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya', id='too_long', @@ -180,6 +167,4 @@ def test_valid_address_invalid(address: str) -> None: def test_valid_address() -> None: """Test if valid_address passes on valid addresses""" - assert Identity.valid_address( - '@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya' - ) + assert Identity.valid_address('@test.bcz76z52y5dlpohtkmpuj3jsdcvfmebzpcgfmtmhu4u7hlexzreya')