Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'yamllint' has no attribute 'config'/'linter' #698

Closed
jamesquilty opened this issue Nov 16, 2024 · 1 comment · Fixed by #699
Closed

AttributeError: module 'yamllint' has no attribute 'config'/'linter' #698

jamesquilty opened this issue Nov 16, 2024 · 1 comment · Fixed by #699

Comments

@jamesquilty
Copy link

The example code in the Development documentation page throws an error for me with yamllint 1.35.1 running on Python 3.12:

$ python3
Python 3.12.4 (main, Jul 13 2024, 16:37:48) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yamllint
>>> yaml_config = yamllint.config.YamlLintConfig("extends: default")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'yamllint' has no attribute 'config'

it will work if I amend the import statement:

>>> from yamllint.config import YamlLintConfig
>>> yaml_config = YamlLintConfig("extends: default")
>>> yaml_config
<yamllint.config.YamlLintConfig object at 0x1033d8710>

The documentation seems Pythonic, so perhaps there's a misconfiguration somewhere?

adrienverge added a commit that referenced this issue Nov 16, 2024
Since yamllint version 0.5.2 (in 2016, just after yamllint was created)
this example in documentation doesn't work. Indeed, commit dbbecb5
(which aimed to solve another problem) removed the ability to import
yamllint submodules directly.

This commit makes it clearer inside documentation.

Fixes #698
@adrienverge
Copy link
Owner

Hello and thanks for the report!

That's true, I confirm this inconsistency in the development section of documentation. It has been the case since 2016 and commit dbbecb5 (just after yamllint was created) to solve another problem.

I propose to fix the documentation to use import yamllint.config instead of import yamllint: #699.

adrienverge added a commit that referenced this issue Nov 20, 2024
Since yamllint version 0.5.2 (in 2016, just after yamllint was created)
this example in documentation doesn't work. Indeed, commit dbbecb5
(which aimed to solve another problem) removed the ability to import
yamllint submodules directly.

This commit makes it clearer inside documentation.

Fixes #698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants