connor-makowski / type_enforced

A pure python type enforcer for annotations. Enforce types in python functions and methods.
MIT License
45 stars 2 forks source link

importerror since 1.0.0 #24

Closed veenstrajelmer closed 12 months ago

veenstrajelmer commented 12 months ago

We recently introduced type_enforced in one of our packages where many others depend on. In the testbanks get importerrors since the release of type_enforced 1.0.0.

C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\meshkernel\meshkernel.py:18: in <module>
    import type_enforced
C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\type_enforced\__init__.py:3: in <module>
    from .enforcer import Enforcer, FunctionMethodEnforcer
C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\type_enforced\enforcer.py:1: in <module>
    from types import FunctionType, MethodType, GenericAlias, UnionType
E   ImportError: cannot import name 'UnionType' from 'types' (C:\Miniconda3\envs\hydromt-delft3dfm\lib\types.py)

This happens in several python versions, but at least py 3.9

Would it be possible to fix this, and include online testing on github?

connor-makowski commented 12 months ago

Thanks for the feedback.

1) For an immediate fix, can you lock to 0.0.16 2) Let me see if I can reproduce this. Then I can add a fix and add some future tests to prevent this from happening in the future.

Connor

On Thu, Nov 16, 2023 at 10:57 AM veenstrajelmer @.***> wrote:

We recently introduced type_enforced in one of our packages where many others depend on. In the testbanks get importerrors since the release of type_enforced 1.0.0.

C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\meshkernel\meshkernel.py:18: in import type_enforced C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\type_enforced__init__.py:3: in from .enforcer import Enforcer, FunctionMethodEnforcer C:\Miniconda3\envs\hydromt-delft3dfm\lib\site-packages\type_enforced\enforcer.py:1: in from types import FunctionType, MethodType, GenericAlias, UnionType E ImportError: cannot import name 'UnionType' from 'types' (C:\Miniconda3\envs\hydromt-delft3dfm\lib\types.py)

This happens in several python versions, but at least py 3.9

— Reply to this email directly, view it on GitHub https://github.com/connor-makowski/type_enforced/issues/24, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3ICWZVVGOB7DRKQN2PL53YEXPRRAVCNFSM6AAAAAA7N3V2PSVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TMNBYGUZTKMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

connor-makowski commented 12 months ago

Thanks for reporting this. This should be fixed in 1.1.1, however I realized that 1.0+ will need to require python>=3.9. This will require yanking 1.0.0 and 1.1.0 from pypi.

See: b58d79f178e8300fe33e70204f4ff9a66aa1fdeb

connor-makowski commented 12 months ago

Can you confirm that this is resolved for you? Feel free to close the issue if it is.

veenstrajelmer commented 12 months ago

It seems to be resolved indeed, the imports work again. Thanks for the quick action.