-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize the codebase, reformat and improve performance #111
Conversation
Changes overview: - Use types from the built-in scope, not the deprecated ones like `typing.List`, `typing.Dict` etc. See [PEP 585](https://peps.python.org/pep-0585/) and [typing docs on built-in types aliases](https://docs.python.org/3/library/typing.html#aliases-to-built-in-types). - Postpone type annotations evaluation in runtime. See [PEP 563](https://peps.python.org/pep-0563/). - Use [PEP 604](https://peps.python.org/pep-0604/) `X | Y` union type syntax. - Use [PEP 613](https://peps.python.org/pep-0613/) explicit type aliases. - Use `typing.TYPE_CHECKING` to separate typing-related imports from the actual runtime requirements.
Via `isort .`
During the review, a special attention should be paid to statements not covered by tests. Coverage report before changes: https://smokeshow.helpmanual.io/3u0g2z34522g3a2k6k4u/ |
Credit to @trag1c for finding this pure gold
@psrok1 I made this PR before a job interview @ NASK (unsuccessful). I'm curious about your feedback though and whether I should continue with the refactor. It inspired me to invent https://github.com/bswck/autorefine. |
This PR contributes to #110 and features various improvements, including:
class T(object):
→class T:
.typing.List
,typing.Dict
etc. See PEP 585 and typing docs on built-in types aliases.X | Y
union type syntax.typing.TYPE_CHECKING
to separate typing-related imports from the actual runtime requirements.super()
inside methods.Path(...).read_(text|bytes)()
andPath(...).write_(text|bytes)()
instead of theopen()
context manager where possible.f"{i:x}"
instead ofhex(i)[2:]
. Act analogically for other numeral systems. More information here.map
/filter
where applicable.type(X)
instead ofX.__class__
where the__class__
's descriptor behavior doesn't matter.StopIteration
when usingnext()
, simply pass a default value as the other argument.Note
To inspect the changes more easily, you might review every commit one-by-one chronologically.
All tests pass on my end.