Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
b553d657
Commit
b553d657
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
slight fix
parent
d4061962
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/coding/structures/singleton.py
+5
-3
5 additions, 3 deletions
satella/coding/structures/singleton.py
with
5 additions
and
3 deletions
satella/coding/structures/singleton.py
+
5
−
3
View file @
b553d657
...
@@ -5,7 +5,6 @@ __all__ = [
...
@@ -5,7 +5,6 @@ __all__ = [
]
]
# Taken from https://wiki.python.org/moin/PythonDecoratorLibrary
def
Singleton
(
cls
):
def
Singleton
(
cls
):
"""
"""
Make a singleton out of decorated class.
Make a singleton out of decorated class.
...
@@ -31,7 +30,8 @@ def Singleton(cls):
...
@@ -31,7 +30,8 @@ def Singleton(cls):
cls
.
__new__
=
singleton_new
cls
.
__new__
=
singleton_new
cls
.
__init_old__
=
cls
.
__init__
cls
.
__init_old__
=
cls
.
__init__
cls
.
__init__
=
lambda
self
,
*
args
,
**
kwargs
:
object
.
__init__
(
self
)
cls
.
__init__
=
functools
.
wraps
(
cls
.
__init__
)(
lambda
self
,
*
args
,
**
kwargs
:
object
.
__init__
(
self
))
return
cls
return
cls
...
@@ -70,7 +70,9 @@ def SingletonWithRegardsTo(num_args: int):
...
@@ -70,7 +70,9 @@ def SingletonWithRegardsTo(num_args: int):
cls
.
__new__
=
singleton_new
cls
.
__new__
=
singleton_new
cls
.
__init_old__
=
cls
.
__init__
cls
.
__init_old__
=
cls
.
__init__
cls
.
__init__
=
lambda
self
,
*
args
,
**
kwargs
:
object
.
__init__
(
self
)
cls
.
__init__
=
functools
.
wraps
(
cls
.
__init__
)(
lambda
self
,
*
args
,
**
kwargs
:
object
.
__init__
(
self
))
return
cls
return
cls
return
inner
return
inner
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment