ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

Allow installing on Python 3.7+ environments #161

Closed jdufresne closed 2 years ago

jdufresne commented 4 years ago

On Python 3.7+ environments, use the builtin dataclasses module instead of shadowing it. This is handled in the dataclasses/init.py which sets the module in sys.modules.

This allows projects to pin dependencies that are then run in both Python 3.6 and 3.7+ environments using tools such as pip-tools.

Previously, if dependencies were pinned for Python 3.6, the dataclasses would be used, but fail to install on Python 3.7+ environments. On the other hand, if dependencies were pinned for Python 3.7+, dataclasses would not be available in Python 3.6 environments.

Projects typically pin dependencies using the oldest supported Python.

dataclasses has recently become a dependency of the popular tool Black, which is how this issue was discovered.

Fixes #153