macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
115 stars 58 forks source link

"ModuleNotFoundError" when using Python 3.12 #181

Closed Delgan closed 11 months ago

Delgan commented 11 months ago

Hi!

Python 3.12 final release is scheduled for the next month and they removed some bundled libraries like notably pkg_resources:

easy_install, pkg_resources, setuptools and distutils are no longer provided by default in environments created with venv or bootstrapped with ensurepip, since they are part of the setuptools package. For projects relying on these at runtime, the setuptools project should be declared as a dependency and installed separately (typically, using pip).

The problem is that language-formatters-pre-commit-hooks depends on pkg_resources here: https://github.com/macisamuele/language-formatters-pre-commit-hooks/blob/9c4cf43ca2527561813f86ad3fa629da8bc68a99/language_formatters_pre_commit_hooks/__init__.py#L2

When using Python 3.12, this causes my pre-commit to fail with the following error:

Traceback (most recent call last):
  File "/home/delgan/.cache/pre-commit/repogd__gv51/py_env-python3.12/bin/pretty-format-yaml", line 5, in <module>
    from language_formatters_pre_commit_hooks.pretty_format_yaml import pretty_format_yaml
  File "/home/delgan/.cache/pre-commit/repogd__gv51/py_env-python3.12/lib/python3.12/site-packages/language_formatters_pre_commit_hooks/__init__.py", line 2, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

I guess setuptools should be added as an explicit dependency to this project in setup.cfg?

macisamuele commented 11 months ago

@Delgan thanks a lot for the report. We do welcome PRs, hence feel free to open one and I'll be happy to review/merge/release it.

Otherwise I'll try to get to it within a week (or so).

Delgan commented 11 months ago

Thanks for the quick reply. I opened #182. ;)

RossKempesinos commented 10 months ago

Would you be able to create a new tag with this included?