python-attrs / cattrs

Composable custom class converters for attrs, dataclasses and friends.
https://catt.rs
MIT License
799 stars 111 forks source link

cattrs ==23.1.1 depends on typing_extensions >4 #372

Closed jvesely closed 1 year ago

jvesely commented 1 year ago

Description

cattrs dependency on typing_extensions doesn't indicate the minimum version needed: Requires-Dist: typing_extensions; python_version < "3.8"

What I Did

$ python3.7 -mvenv test-venv
$ source test-venv/bin/activate
$ pip install cattrs==23.1.1 'typing_extensions<4'
$ python -c 'import cattrs'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/test-venv/lib/python3.7/site-packages/cattrs/__init__.py", line 1, in <module>
    from .converters import BaseConverter, Converter, GenConverter, UnstructureStrategy
  File "/root/test-venv/lib/python3.7/site-packages/cattrs/converters.py", line 26, in <module>
    from ._compat import (
  File "/root/test-venv/lib/python3.7/site-packages/cattrs/_compat.py", line 177, in <module>
    from typing_extensions import Annotated, NotRequired, Required
ImportError: cannot import name 'NotRequired' from 'typing_extensions' (/root/test-venv/lib/python3.7/site-packages/typing_extensions.py)

cattr==22.2.0 works ok. allowing typing_extensions >=4 also works around the problem

Tinche commented 1 year ago

Right you are, but I think is already fixed on main. Can you verify?

jvesely commented 1 year ago

Right you are, but I think is already fixed on main. Can you verify?

right! looks like https://github.com/python-attrs/cattrs/commit/0cb1872cc8459e61075778252ce0acb5d44abaa7 added the lower bound. Any plans for a release with his fix?

Tinche commented 1 year ago

I published 23.1.2 with the fix, let me know!

jvesely commented 1 year ago

looks like it worked:

root@60246eb5a736:~# python3.7 -m venv test-venv
root@60246eb5a736:~# source test-venv/bin/activate
(test-venv) root@60246eb5a736:~# pip install -U pip
Cache entry deserialization failed, entry ignored
Collecting pip
  Using cached https://files.pythonhosted.org/packages/08/e3/57d4c24a050aa0bcca46b2920bff40847db79535dc78141eb83581a52eb8/pip-23.1.2-py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-23.1.2
(test-venv) root@60246eb5a736:~# pip install cattrs 'typing_extensions<4'
Collecting cattrs
  Using cached cattrs-23.1.2-py3-none-any.whl (50 kB)
Collecting typing_extensions<4
  Using cached typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Collecting attrs>=20 (from cattrs)
  Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting exceptiongroup (from cattrs)
  Using cached exceptiongroup-1.1.1-py3-none-any.whl (14 kB)
INFO: pip is looking at multiple versions of cattrs to determine which version is compatible with other requirements. This could take a while.
Collecting cattrs
  Using cached cattrs-23.1.1-py3-none-any.whl (50 kB)
Collecting importlib-metadata (from attrs>=20->cattrs)
  Using cached importlib_metadata-6.6.0-py3-none-any.whl (22 kB)
Collecting zipp>=0.5 (from importlib-metadata->attrs>=20->cattrs)
  Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)
Installing collected packages: typing_extensions, zipp, exceptiongroup, importlib-metadata, attrs, cattrs
Successfully installed attrs-23.1.0 cattrs-23.1.1 exceptiongroup-1.1.1 importlib-metadata-6.6.0 typing_extensions-3.10.0.2 zipp-3.15.0

pip falls back to 23.1.1.

thank you