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

Avoid mutable global state in SettingsWrapper #1097

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

bluetech
Copy link
Member

No description provided.

@bluetech bluetech merged commit 12cf877 into pytest-dev:master Nov 10, 2023
17 checks passed
@bluetech bluetech deleted the settings-classvar branch November 10, 2023 11:38
@@ -498,7 +497,9 @@ def async_rf() -> django.test.AsyncRequestFactory:


class SettingsWrapper:
_to_restore: ClassVar[list[Any]] = []
def __init__(self) -> None:
self._to_restore: list[django.test.override_settings]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type declaration can remain at the class level, like in a stub. IMO a little more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to make it look like self._to_restore: list[django.test.override_settings] = []

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair, I guess type checkers support it.

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.

None yet

2 participants