Skip to content

Commit

Permalink
bug fix packaging + fix printing with deletion of str()
Browse files Browse the repository at this point in the history
  • Loading branch information
bleudev committed Jun 10, 2024
1 parent 29285d9 commit ba9ac41
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ cython_debug/

# Tests
tests.py

# PyPi
.pypirc
15 changes: 2 additions & 13 deletions examples/udict.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,16 @@ 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)
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
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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',
Expand Down
18 changes: 11 additions & 7 deletions ufpy/__init__.py
Original file line number Diff line number Diff line change
@@ -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 *
4 changes: 2 additions & 2 deletions ufpy/typ/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .protocols import *
from .type_alias import *
from ufpy.typ.protocols import *
from ufpy.typ.type_alias import *
2 changes: 1 addition & 1 deletion ufpy/typ/type_alias.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Never

from .protocols import LikeDict
from ufpy.typ.protocols import LikeDict

__all__ = (
'AnyCollection',
Expand Down
11 changes: 4 additions & 7 deletions ufpy/udict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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}'

Expand Down
6 changes: 3 additions & 3 deletions ufpy/ustack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ufpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 10 additions & 0 deletions upload_testpypi.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ba9ac41

Please sign in to comment.