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 config models to dataclasses #4525

Closed
stsewd opened this issue Aug 15, 2018 · 3 comments
Closed

Refactor config models to dataclasses #4525

stsewd opened this issue Aug 15, 2018 · 3 comments
Labels
Improvement Minor improvement to code Status: blocked Issue is blocked on another issue
Milestone

Comments

@stsewd
Copy link
Member

stsewd commented Aug 15, 2018

Currently, we are using namedtuples. A problem with this is that you can't have default values when we move to python3 in production (3.7) we can refactor those to dataclasses.

Pros:

  • Default values
  • Type hints
  • Less repetition
  • Our code looks more cool 😎

ref #4456 (comment)

@stsewd stsewd added the Improvement Minor improvement to code label Aug 15, 2018
@stsewd stsewd added this to the Refactoring milestone Aug 15, 2018
@ba11b0y
Copy link
Contributor

ba11b0y commented Sep 14, 2018

Taking this up. Confirming that the dataclasses should be immutable?
Also where do I refer for the defaults?

@stsewd
Copy link
Member Author

stsewd commented Sep 14, 2018

@invinciblycool we don't run python 3.7 in production yet, I'll mark this issue as blocked till that.

Answering your questions, yes, it should be immutable, we can search the default here https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/config/config.py

@stsewd stsewd added the Status: blocked Issue is blocked on another issue label Sep 14, 2018
@stsewd
Copy link
Member Author

stsewd commented Jan 30, 2019

We move to use plain classes + __slots__ for now, closing.

@stsewd stsewd closed this as completed Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Status: blocked Issue is blocked on another issue
Projects
None yet
Development

No branches or pull requests

2 participants