diff --git a/README.md b/README.md index cc5ff41..7500b6f 100644 --- a/README.md +++ b/README.md @@ -40,18 +40,6 @@ conda activate zeeland pip install poetry ``` -Then you can run the client using the following command: - -```bash -zeeland --help -``` - -or with `Poetry`: - -```bash -poetry run zeeland --help -``` - ### Basic Usage Create a metadata file in the default storage path. @@ -82,6 +70,35 @@ if __name__ == "__main__": main() ``` +Singleton usage + +```python +from zeeland import Singleton, singleton + + +@singleton() +class TestSingleton: + pass + + +instance1 = TestSingleton() +instance2 = TestSingleton() + +assert instance1 is instance2 + + +class TestSingletonWithArgs(metaclass=Singleton): + def __init__(self, value): + self.value = value + + +instance1 = TestSingletonWithArgs("test1") +instance2 = TestSingletonWithArgs("test2") + +assert instance1 is instance2 +assert instance1.value == "test1" +``` + ### Makefile usage [`Makefile`](https://github.com/Undertone0809/zeeland/blob/main/Makefile) contains a lot of functions for faster development. diff --git a/examples/singleton_usage.py b/examples/singleton_usage.py new file mode 100644 index 0000000..9f4e4cc --- /dev/null +++ b/examples/singleton_usage.py @@ -0,0 +1,24 @@ +from zeeland import Singleton, singleton + + +@singleton() +class TestSingleton: + pass + + +instance1 = TestSingleton() +instance2 = TestSingleton() + +assert instance1 is instance2 + + +class TestSingletonWithArgs(metaclass=Singleton): + def __init__(self, value): + self.value = value + + +instance1 = TestSingletonWithArgs("test1") +instance2 = TestSingletonWithArgs("test2") + +assert instance1 is instance2 +assert instance1.value == "test1" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c46a08..0000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[darglint] -# https://github.com/terrencepreilly/darglint -strictness = long -docstring_style = google