4

I am getting an error from importlib_metadata AttributeError: 'EntryPoints' object has no attribute 'get' during pre-commit install even though I have already installed importlib_metadata==4.13.0 as suggested by below StackOverflow answer. What I am doing wrong here?

This is my pre-commit config yaml file that I am using -

exclude: 'settings.py'
fail_fast: true
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks.git
    rev: v4.0.1
    hooks:
    -   id: trailing-whitespace
    -   id: check-yaml
    -   id: check-json
    -   id: check-docstring-first
    -   id: requirements-txt-fixer
    -   id: debug-statements
    -   id: check-toml
    -   id: pretty-format-json
        args: [--autofix]
    -   id: no-commit-to-branch
        args: [--branch, develop, --branch, master]

-   repo: https://github.com/pycqa/isort
    rev: 5.11.5
    hooks:
    -   id: isort
        name: isort
        exclude: ^site-pacakges/

-   repo: https://github.com/asottile/pyupgrade
    rev: v2.26.0
    hooks:
    -   id: pyupgrade
        exclude: ^site-pacakges/
        args: ["--py37-plus"]

-   repo: https://github.com/psf/black
    rev: 23.1.0
    hooks:
    -   id: black
        exclude: ^site-pacakges/
        language_version: python3.7

-   repo: https://github.com/PyCQA/flake8
    rev: 3.9.2
    hooks:
    -   id: flake8
        additional_dependencies: [flake8-typing-imports==1.10.0]
        exclude: ^site-pacakges/

-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.910
    hooks:
    -   id: mypy
        name: Mypy typing checks
        args: ["--config-file=pyproject.toml"]
        exclude: ^site-pacakges/

-   repo: local
    hooks:
    -   id: tests
        name: run tests
        entry: pytest
        pass_filenames: false
        language: system


Possible duplicate - 'EntryPoints' object has no attribute 'get'

Error generating from flake8

  File "/Users/X/.cache/pre-commit/repo_fr5yg6d/py_env-python3.7/lib/python3.7/site-packages/flake8/plugins/manager.py", line 254, in _load_entrypoint_plugins
    eps = importlib_metadata.entry_points().get(self.namespace, ())
AttributeError: 'EntryPoints' object has no attribute 'get
1
  • 2
    Upgrade your flake8. The newest versions do not hit this issue
    – AmaJayJB
    Commented Dec 11, 2023 at 7:12

1 Answer 1

3

with importlib-metadata==4.8.3 and with the below config. I was able to resolve this issue.

exclude: 'settings.py'
fail_fast: true
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks.git
    rev: v4.0.1
    hooks:
    -   id: trailing-whitespace
    -   id: check-yaml
    -   id: check-json
    -   id: check-docstring-first
    -   id: requirements-txt-fixer
    -   id: debug-statements
    -   id: check-toml
    -   id: pretty-format-json
        args: [--autofix]
    -   id: no-commit-to-branch
        args: [--branch, develop, --branch, master]

-   repo: https://github.com/pycqa/isort
    rev: 5.11.5
    hooks:
    -   id: isort
        name: isort
       exclude: ^site-pacakges/

-   repo: https://github.com/asottile/pyupgrade
    rev: v2.26.0
    hooks:
    -   id: pyupgrade
       exclude: ^site-pacakges/
        args: [--py37-plus]

-   repo: https://github.com/psf/black
    rev: 23.1.0
    hooks:
    -   id: black
       exclude: ^site-pacakges/
        language_version: python3.7

-   repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
    -   id: flake8
        additional_dependencies: [flake8-typing-imports==1.10.0]
        exclude: ^site-pacakges/

-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.910
    hooks:
    -   id: mypy
        name: Mypy typing checks
        args: ["--config-file=pyproject.toml"]
        exclude: site-pacakges/

-   repo: local
    hooks:
    -   id: tests
        name: run tests
        entry: pytest
        pass_filenames: false
        language: system

Not the answer you're looking for? Browse other questions tagged or ask your own question.