Skip to content
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

Refactor modules #26

Merged
merged 3 commits into from
Jul 5, 2023
Merged

Refactor modules #26

merged 3 commits into from
Jul 5, 2023

Conversation

mdumandag
Copy link
Contributor

There were lots of tiny modules, which is not idiomatic Python. I have replaced most of those, and simplified the module structure of the client a lot. Most of these are simple moves without a code change.

Apart from that, I have applied isort and black to whole code base. I plan to add them to CI in the short term as well, in another PR.

Below, I list other small changes I did as part of this PR:

  • Moved types that are mentioned in the public APIs to typing.py
  • Renamed UpstashException to UpstashError, as the errors that originate from the Exception class are prefixed with Error throughout the standard library and ecosystem.
  • Converted the type of the rest_encoding parameter from boolean | Literal["base64"] to None | Literal["base64"]. I believe it conveys the message better.
  • Removed the mix-in class FormattedResponse altogether. It was not providing any benefit other than providing the dict of formatters. I converted it into a simple dictionary.
  • Converted the rest_retry_interval parameter into a float from int. Time related parameters are generally given as floats that represent seconds. It also makes more sense, as you now able to provide more granular times.
  • Removed CommandsProtocol altogether. That abstraction was not used at all.
  • Removed some commented out codes. I don't like the idea of shipping dead code, we can implement them properly later.

There were lots of tiny modules, which is not idiomatic Python.
I have replaced most of those, and simplified the module structure
of the client a lot. Most of these are simple moves without
a code change.

Apart from that, I have applied isort and black to whole code
base. I plan to add them to CI in the short term as well, in another
PR.

Below, I list other small changes I did as part of this PR:

- Moved types that are mentioned in the public APIs to typing.py
- Renamed UpstashException to UpstashError, as the errors that
originate from the `Exception` class are prefixed with Error
throughout the standard library and ecosystem.
- Converted the type of the `rest_encoding` parameter from
`boolean | Literal["base64"]` to `None | Literal["base64"]`. I
believe it conveys the message better.
- Removed the mix-in class `FormattedResponse` altogether. It was
not providing any benefit other than providing the dict of
formatters. I converted it into a simple dictionary.
- Converted the `rest_retry_interval` parameter into a `float` from
`int`. Time related parameters are generally given as floats that
represent seconds. It also makes more sense, as you now able to
provide more granular times.
- Removed `CommandsProtocol` altogether. That abstraction was
not used at all.
- Removed some commented out codes. I don't like the idea of
shipping dead code, we can implement them properly later.
@burak-upstash burak-upstash merged commit d235fec into main Jul 5, 2023
1 check passed
@burak-upstash burak-upstash deleted the refactor-modules branch July 5, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants