-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Use a metaclass to implement the singleton pattern #340
Conversation
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.
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.
CI failing.
@kwist-sgr https://github.com/tox-dev/sphinx-autodoc-typehints/actions/runs/9583644379/job/26425402570 seems broke the world had to yank it... |
To be fair it seems virtualenv is violating the contract by not implementing the proper signature of |
The thing is that all other args past the lockfile should be optional... or they were, so without making it a breaking change we can't suddenly require downstream to have this optional args... |
Hmm actually never mind, that doesn't make sense with the error |
OK I understand @gaborbernat's explanation. Yeah looking further, beyond just the super call, the |
@gaborbernat Oh. I apologize. I'm going to create a fix |
Reason
More correct implementation of the
singleton
pattern.There is a problem with the current implementation: class's
__init__
to be called again wheneverlock_class(is_singleton=True)
is called, which is at least not obvious (also, it'll lead to the re-initializing instance's internal objects, e.g.: virtualenv/util/lock.py)What was done in this PR
FileLockMeta
/AsyncFileLockMeta
used as metaclasses forBaseFileLock
/BaseAsyncFileLock
__init__
method is called only onceRelated PRs