Post-ruff minor issues
Closed this issue · 3 comments
qstokkink commented
Now that all the core IPv8 logic has had its ruff
issues fixed, including its types, I'm left with a list of minor issues that should be solved at some point:
- Both
TestBase
andDiscoveryStrategy
should be turned intoGeneric[SomeOverlayType]
. WHY: Having to assure mypy that they were loaded with a particular type of overlay, at runtime, is a pain. Fixed in #1181 and #1192 - Create a
CommunityConfig
(or a dictionary) to storeCommunity
configurations. WHY: We now have 6 arguments to theCommunity
constructor and, not only is this triggeringPLR0913
everywhere, this leads to mass repetition of the default arguments. - Related to the previous point: the docs should be updated accordingly.
-
PD011
is throwing false-positivenumpy
errors and should be disabled. WHY: We don't usenumpy
. Fixed in #1190 - The
RequestCache
should type its return values. WHY: Currently we need to cast all of the results ofpop()
from theRequestCache
. Fixed in #1191 - We could shorten some types to be more descriptive. WHY: We now have very long types which are (probably) correct but - for example - one
bytes
may describe a 20 byte infohash while the other is a 64 byte public key. Fixed in #1197
qstokkink commented
I'll handle the TestBase
generic-ification in the test
folder PR.
EDIT: fixed in #1181
qstokkink commented
The RequestCache should type its return values.
To be consistent with the implementation of retrieve_cache
, we can demand that NumberCache
s specify a name
. Then we can simply call the old pop implementation using that value (RequestCache.pop(cache.name: str, number: int)
) when RequestCache(cache: CacheTypeVar, number: int) -> CacheTypeVar
is invoked.
qstokkink commented
A TypedDict
may be a good way to implement a CommunityConfig
(or CommunitySettings
) object.