From ba9ac41f69c5aeeeda4222a8a16e6f9caa0b41bd Mon Sep 17 00:00:00 2001 From: bleudev Date: Mon, 10 Jun 2024 19:57:37 +0300 Subject: [PATCH 1/5] bug fix packaging + fix printing with deletion of `str()` --- .gitignore | 3 +++ examples/udict.md | 15 ++------------- setup.py | 7 ++++--- ufpy/__init__.py | 18 +++++++++++------- ufpy/typ/__init__.py | 4 ++-- ufpy/typ/type_alias.py | 2 +- ufpy/udict.py | 11 ++++------- ufpy/ustack.py | 6 +++--- ufpy/utils.py | 2 +- upload_testpypi.bat | 10 ++++++++++ 10 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 upload_testpypi.bat diff --git a/.gitignore b/.gitignore index b260254..be77165 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,6 @@ cython_debug/ # Tests tests.py + +# PyPi +.pypirc \ No newline at end of file diff --git a/examples/udict.md b/examples/udict.md index 3033026..7a20df5 100644 --- a/examples/udict.md +++ b/examples/udict.md @@ -174,11 +174,9 @@ print(('hi', 1) in d) # True print(('hi', 11) in d) # False ``` -## Convert to `str` type and using in `print` +## Using in `repr()` method -### Print dict - -`print` uses `repr()` therefore `UDict` supports `repr()` +`print()` uses `repr()` therefore you can use `UDict`s in `print()` ```python d = UDict(hi=1, hello=2) @@ -186,15 +184,6 @@ print(d) # u{'hi': 1, 'hello': 2} print(repr(d)) # u{'hi': 1, 'hello': 2} ``` -### Convert to str - -You can use inbuilt `str()` class for converting `UDict` to `str` type - -```python -d = UDict(hi=1, hello=2) -print(str(d)) # {'hi': 1, 'hello': 2} -``` - ## Comparing dicts You can compare `UDict`s using inbuilt compare operators diff --git a/setup.py b/setup.py index 65ee341..93029ba 100644 --- a/setup.py +++ b/setup.py @@ -5,8 +5,9 @@ with open('README.md', 'r', encoding='utf-8') as mdf: long_description = mdf.read() -with open('requirements.txt', 'r', encoding='utf-8') as rqf: - install_requires = rqf.readlines() +install_requires = [ + +] organization_name = 'honey-team' author, author_email = 'bleudev', 'aitiiigg1@gmail.com' @@ -23,7 +24,7 @@ long_description=long_description, long_description_content_type='text/markdown', url=github_url, - packages=[project_name], + packages=[project_name, f'{project_name}.typ'], classifiers=[ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.12', diff --git a/ufpy/__init__.py b/ufpy/__init__.py index f737223..830349f 100644 --- a/ufpy/__init__.py +++ b/ufpy/__init__.py @@ -1,8 +1,12 @@ -__version__ = '0.1.1' +__version__ = '0.1.1.2' -from .cmp import * -from .math_op import * -from .path_tools import * -from .udict import * -from .ustack import * -from .utils import * +# Typing package +from ufpy import typ +from ufpy.cmp import * +from ufpy.math_op import * +from ufpy.path_tools import * +from ufpy.typ.protocols import * +from ufpy.typ.type_alias import * +from ufpy.udict import * +from ufpy.ustack import * +from ufpy.utils import * diff --git a/ufpy/typ/__init__.py b/ufpy/typ/__init__.py index d5820fa..05dac70 100644 --- a/ufpy/typ/__init__.py +++ b/ufpy/typ/__init__.py @@ -1,2 +1,2 @@ -from .protocols import * -from .type_alias import * +from ufpy.typ.protocols import * +from ufpy.typ.type_alias import * diff --git a/ufpy/typ/type_alias.py b/ufpy/typ/type_alias.py index 374ae00..bcb1303 100644 --- a/ufpy/typ/type_alias.py +++ b/ufpy/typ/type_alias.py @@ -1,6 +1,6 @@ from typing import Never -from .protocols import LikeDict +from ufpy.typ.protocols import LikeDict __all__ = ( 'AnyCollection', diff --git a/ufpy/udict.py b/ufpy/udict.py index f5faa58..5bba9a5 100644 --- a/ufpy/udict.py +++ b/ufpy/udict.py @@ -2,10 +2,10 @@ from typing import Generic, Iterator, overload, TypeVar, Callable -from .cmp import cmp_generator -from .math_op import i_generator, r_generator -from .typ import AnyDict, AnyCollection -from .utils import set_items_for_several_keys, get_items_for_several_keys, del_items_for_several_keys +from ufpy.cmp import cmp_generator +from ufpy.math_op import i_generator, r_generator +from ufpy.typ import AnyDict, AnyCollection +from ufpy.utils import set_items_for_several_keys, get_items_for_several_keys, del_items_for_several_keys __all__ = ( 'UDict', @@ -243,9 +243,6 @@ def __contains__(self, item: tuple[KT, VT] | list[KT | VT] | KT) -> bool: return item in self.__dict # Transform to other types - def __str__(self) -> str: - return str(self.__dict) - def __repr__(self) -> str: return f'u{self.__dict}' diff --git a/ufpy/ustack.py b/ufpy/ustack.py index 14dcd8d..f8aad74 100644 --- a/ufpy/ustack.py +++ b/ufpy/ustack.py @@ -2,9 +2,9 @@ from typing import Generic, TypeVar, Iterable, Callable -from .cmp import cmp_generator -from .math_op import r_generator, i_generator -from .typ import AnyCollection, NumberLiteral, SupportsMul, SupportsTrueDiv, Empty +from ufpy.cmp import cmp_generator +from ufpy.math_op import r_generator, i_generator +from ufpy.typ import AnyCollection, NumberLiteral, SupportsMul, SupportsTrueDiv, Empty __all__ = ( "UStack", diff --git a/ufpy/utils.py b/ufpy/utils.py index a975752..3d3a984 100644 --- a/ufpy/utils.py +++ b/ufpy/utils.py @@ -6,7 +6,7 @@ from typing import TypeVar -from .typ import SupportsGet, SupportsSetItem, SupportsDelItem, AnyCollection +from ufpy.typ import SupportsGet, SupportsSetItem, SupportsDelItem, AnyCollection KT = TypeVar('KT') VT = TypeVar('VT') diff --git a/upload_testpypi.bat b/upload_testpypi.bat new file mode 100644 index 0000000..13d00e9 --- /dev/null +++ b/upload_testpypi.bat @@ -0,0 +1,10 @@ +@echo off +py -3.12 -m pip install --upgrade pip +py -3.12 -m pip install setuptools twine +py -3.12 setup.py sdist + +py -3.12 -m twine upload --repository testpypi dist\* + +rd /s /q ufpy.egg-info +rd /s /q dist +rd /s /q build From 580c9c598597b1790ed183079960f555108889e9 Mon Sep 17 00:00:00 2001 From: bleudev <95937737+bleudev@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:02:55 +0300 Subject: [PATCH 2/5] Update examples/udict.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- examples/udict.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/udict.md b/examples/udict.md index 7a20df5..a51d936 100644 --- a/examples/udict.md +++ b/examples/udict.md @@ -174,7 +174,7 @@ print(('hi', 1) in d) # True print(('hi', 11) in d) # False ``` -## Using in `repr()` method +## Using `repr()` and `print()` `print()` uses `repr()` therefore you can use `UDict`s in `print()` From fa191844de557fbdfc17ad1ca3565d5391fc12b8 Mon Sep 17 00:00:00 2001 From: bleudev <95937737+bleudev@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:03:26 +0300 Subject: [PATCH 3/5] Update examples/udict.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- examples/udict.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/udict.md b/examples/udict.md index a51d936..3b5e1d3 100644 --- a/examples/udict.md +++ b/examples/udict.md @@ -176,7 +176,7 @@ print(('hi', 11) in d) # False ## Using `repr()` and `print()` -`print()` uses `repr()` therefore you can use `UDict`s in `print()` +Since `print()` uses `repr()`, you can directly print `UDict` objects. ```python d = UDict(hi=1, hello=2) From aafb7abc9cadfc12201e14aa46633a7dcf31ceb3 Mon Sep 17 00:00:00 2001 From: bleudev Date: Mon, 10 Jun 2024 20:04:56 +0300 Subject: [PATCH 4/5] change version --- ufpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ufpy/__init__.py b/ufpy/__init__.py index 830349f..e15f6f8 100644 --- a/ufpy/__init__.py +++ b/ufpy/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.1.1.2' +__version__ = '0.1.2' # Typing package from ufpy import typ From e640ed53de2b0435c046a2e328f97becbd95c72b Mon Sep 17 00:00:00 2001 From: bleudev Date: Mon, 10 Jun 2024 20:07:23 +0300 Subject: [PATCH 5/5] fix tests with `str()` --- tests/test_udict.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_udict.py b/tests/test_udict.py index 53251aa..58944c9 100644 --- a/tests/test_udict.py +++ b/tests/test_udict.py @@ -147,11 +147,10 @@ def test_contains(self): self.assertTrue(('hi', 2) in d) self.assertFalse(('hi', 1) in d) - def test_str_and_repr(self): + def test_repr(self): d = {'hello': 1, 'hi': 2} ud = UDict(d) - self.assertEqual(str(ud), str(d)) self.assertEqual(repr(ud), f'u{repr(d)}') def test_cmp_and_eq(self):