Skip to content

Commit

Permalink
v0.23.10: style(lint): turn on "ARG" flag & fix associated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rmlibre committed Jul 5, 2024
1 parent 0dee669 commit 8c140a6
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Minor Changes
- fix(concurrency): rely on context manager boolean control flow
- docs(coc): fix typos & rename first section
- docs(concurrency): fix typos & grammar in doc strings
- style(lint): turn on "ARG" flag & fix associated warnings



Expand Down
2 changes: 1 addition & 1 deletion aiootp/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __await__(self, /) -> t.Self:
yield
return self

def __call__(self, /, *a, **kw) -> t.Self:
def __call__(self, /, *_, **__) -> t.Self:
return self

def __bool__(self, /) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion aiootp/_permutations/fast_affine_xor_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _initialize_permutations(
"""
cid = self.config.PERMUTATION_CONFIG_ID
Permutation = self.config.Permutation
aff = Permutation(key=key_reader(), config_id=cid)
aff = Permutation(key=key_reader(size), config_id=cid)
return (aff, aff, aff)


Expand Down
2 changes: 1 addition & 1 deletion aiootp/asynchs/aos.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from .loops import asleep, wrap_in_executor


async def not_implemented_placeholder(*a: t.Any, **kw: t.Any) -> None:
async def not_implemented_placeholder(*_: t.Any, **__: t.Any) -> None:
# fmt: off
await asleep() # pragma: no cover
warnings.warn("Function not supported by OS.") # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions aiootp/ciphers/stream_hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _for_decryption(self) -> t.Self:
self._avalidated_transform = self._ahash_then_decipher
return self

async def _aplaceholder_update(self, *a: t.Any, **kw: t.Any) -> None:
async def _aplaceholder_update(self, *_: t.Any, **__: t.Any) -> None:
"""
This method is overwritten with the propper functionality when a
cipher mode is declared with either the `_for_encryption` or
Expand All @@ -157,7 +157,7 @@ async def _aplaceholder_update(self, *a: t.Any, **kw: t.Any) -> None:
"""
raise SHMACIssue.no_cipher_mode_declared()

def _placeholder_update(self, *a: t.Any, **kw: t.Any) -> None:
def _placeholder_update(self, *_: t.Any, **__: t.Any) -> None:
"""
This method is overwritten with the propper functionality when a
cipher mode is declared with either the `_for_encryption` or
Expand Down
5 changes: 4 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ target-version = "py38"
select = [
# "A", # TODO: decide on using module __doc__ or not
"FLY", # flynt
# "ARG", # TODO: cleaning up so this passes is a goal
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"C", # conventions & complexity
Expand Down Expand Up @@ -98,6 +98,9 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
"**/randoms/simple.py" = [
"S311", # weak random is labelled in simple module
]
"**/databases/{async,sync}_database.py" = [
"ARG002", # temporary, until `admin` kwarg (non-)usage is decided
]
"dual_output_shake_cipher_config.py" = [
"SIM114", # TODO: specify branch exceptions & other build limits
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_X25519_Ed25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def basic_sync_tests(tested_class):
secret_key_b.import_secret_key(secret_key_b.secret_bytes)


async def test_X25519(database, async_database):
async def test_X25519():
# Test class constructors
secret_key_a = await X25519().agenerate()
secret_key_b = X25519().generate()
Expand Down Expand Up @@ -448,7 +448,7 @@ async def test_triple_diffie_hellman_interop(self) -> None:
assert client_kdf.sha3_512() == server_kdf.sha3_512()


async def test_Ed25519(database, async_database):
async def test_Ed25519():
# Test class constructors
secret_key_a = await Ed25519().agenerate()
secret_key_b = Ed25519().generate()
Expand Down
13 changes: 13 additions & 0 deletions tests/test_affine_permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@ async def test_subkeys_non_overlapping_slices_of_input_key(
)
assert key == self.recomposed_key(aff)

async def test_invalid_key_size_is_disallowed(self) -> None:
problem = (
"An invalid input key size was allowed during initialization."
)
for size in _test_sizes:
key = _key[: self._type.key_size(config_id=size) - 1]
with Ignore(ValueError, if_else=violation(problem)):
self._type(key=key, config_id=size)

key = _key[: self._type.key_size(config_id=size) + 1]
with Ignore(ValueError, if_else=violation(problem)):
self._type(key=key, config_id=size)

async def test_permutation_is_correctly_invertible(self) -> None:
for size in _test_sizes:
key = _key[: self._type.key_size(config_id=size)]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_config_id_cannot_change(
assert config.CONFIG_ID == 1

def test_config_must_be_config_subclass(
self, config: t.ConfigType, mapping: ConfigMap
self, mapping: ConfigMap
) -> None:
problem = ( # fmt: skip
"non-`Config` subclass was allowed to be registered."
Expand Down

0 comments on commit 8c140a6

Please sign in to comment.