-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Stop using config at import #397
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
Stop using config at import #397
Conversation
…package by adding a config/__init__.py file. This will make it easier to continue refactoring the config system later
… class definition. Also add tests for this fact in tests/test_coordinate_system.py.
…so, fix mobject which was using the deprecated config[VIDEO_DIR]
|
@huguesdevimeux @Aathish04 the |
I think this'll clear up a lot of confusion regarding exactly what config is used for which test. Eagerly awaiting the PR! |
huguesdevimeux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. One step more against CONFIG !
…nim into pr/stop-using-config-at-import
Context
This PR belongs to the ongoing refactor of the config system (#337).
Main change
The main goal here is to use the
configdict as little as possible during library initialization. After this PR,configis only being used by a class/instance after the library has been imported (and thus after all other classes/functions/variables are already defined).The motivation
The current state of the codebase contains a lot of
CONFIGdictionaries as class attributes. Some of these have keys that are set using the value of the globalconfigdict. Since all classes (and therefore all class attributes) are defined as soon as the library is being imported, all of theCONFIGattributes contain keys that are set to the values ofconfigat the time when the library is first imported. This means that if a user/dev tries to change theconfigin the middle of a python session (for example, to perform tests), theCONFIGattributes will not reflect those changes. This is Bad. This PR changes the Bad to Good.List of changes
CONFIGto the__init__method of the class.tests/test_coordinate_system.pytests. I chose the CoordinateSystem class to be tested because itsCONFIGis being changed by this PR in a way that interacts with inheritance in non-trivial ways. The tests pass so I'm happy.Future work
I believe this will be fine in terms of moving to
attrs. Most of the attributes now defined in__init__can easily be defined in__post__init__or whatever it is.NOTE: whoever merges this, please make sure to squash and delete all of the "merge X into Y" messages from the final commit....