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

Astroid 2.12 breaks sphinx autoapi (at least for Airflow) #1708

Closed
potiuk opened this issue Jul 11, 2022 · 10 comments · Fixed by #1714
Closed

Astroid 2.12 breaks sphinx autoapi (at least for Airflow) #1708

potiuk opened this issue Jul 11, 2022 · 10 comments · Fixed by #1714

Comments

@potiuk
Copy link

potiuk commented Jul 11, 2022

Steps to reproduce

  1. Checkout apache airlfow (https://github.com/apache/airflow)
  2. Install airflow with doc extras pip install ".[doc]"
  3. Make sure to use latest astroid version pip install --upgrade astroid (2.12.1 should be installed)
  4. export PYTHONPATH=$(pwd)
  5. ./docs/build_docs.py --package-filter apache-airflow --one-pass-only --docs-only
  6. docs build fails with 111 errors similar to:
------------------------------ Error  95 --------------------
  File "/usr/local/lib/python3.7/site-packages/astroid/nodes/node_ng.py", line 182, in infer
------------------------------ Error  96 --------------------
  File "/usr/local/lib/python3.7/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1842, in _is_metaclass
  1. downgrade astroid to 2.11.7: pip install astroid==2.11.7
  2. ./docs/build_docs.py --package-filter apache-airflow --one-pass-only --docs-only
  3. Observe the build succeeds.

NOTE. The above might fail because of libenchant could not be installed (especially on MacOS silicon)
You can reproduce it easily using our CI docker image - with all dependencies needed installed:

  1. docker run -it ghcr.io/apache/airflow/main/ci/python3.7:2af19f16a4d94e749bbf6c7c4704e02aac35fc11
  2. ./docs/build_docs.py --package-filter apache-airflow --one-pass-only --docs-only
  3. docs build fails with 111 errors similar to:
------------------------------ Error  95 --------------------
  File "/usr/local/lib/python3.7/site-packages/astroid/nodes/node_ng.py", line 182, in infer
------------------------------ Error  96 --------------------
  File "/usr/local/lib/python3.7/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1842, in _is_metaclass
  1. downgrade astroid to 2.11.7: pip install astroid==2.11.7
  2. ./docs/build_docs.py --package-filter apache-airflow --one-pass-only --docs-only
  3. Observe the build succeeds.

Also downgrading to 2.12.0 leads to failures.
Example failure in CI: https://github.com/apache/airflow/runs/7291353339?check_suite_focus=true#step:9:6115

Current behavior

Version 2.12.* of astroid causes sphinx autoapi to fail
Version 2.11.7 of astroid and before works.

Expected behavior

  • Version 2.12.* of astroid should work with sphinx autoapi
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
2.12.1
potiuk added a commit to potiuk/airflow that referenced this issue Jul 11, 2022
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.
potiuk added a commit to apache/airflow that referenced this issue Jul 12, 2022
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.
@DanielNoord
Copy link
Collaborator

DanielNoord commented Jul 12, 2022

Thanks for the report! Failing action.

The offending line is something like this:

packages/astroid/interpreter/_import/spec.py", line 204, in find_module
submodule_path = sys.modules.__path__
AttributeError: module 'http.client' has no attribute '__path__'

Either we incorrectly classify http.client as a namespace package:
https://github.com/PyCQA/astroid/blob/c9425824b06adc654ca2d5f7b1471f65f74f64f6/astroid/interpreter/_import/spec.py#L203

Or it is a namespace package with a mangled __path__ attribute.

@jacobtylerwalls Does this ring a bell?

@jacobtylerwalls
Copy link
Member

Thanks for the report. Looks like we need to add a hasattr guard. I noticed the failing job is running python 3.7? Is it reproducible on later versions?

@potiuk
Copy link
Author

potiuk commented Jul 12, 2022

Yep. same problems on 3.10 at least.

@potiuk
Copy link
Author

potiuk commented Jul 12, 2022

BTW. I you have a candidate to test, I am happy to test it. For now we limited astroid to < 2.12 so we are good, but we do not like to keep the upper-binding on our dependencies :).

@jacobtylerwalls
Copy link
Member

@potiuk If you wanted to test #1714 that would be fantastic. I'm worried you might run into benjaminp/six#261, but there is a workaround listed there.

@potiuk
Copy link
Author

potiuk commented Jul 16, 2022

On it.

@potiuk
Copy link
Author

potiuk commented Jul 16, 2022

Yep. Confirmed it fixes the problem (though some tests are failing for you :P ) .

apache-airflow                                              : Building documentation
apache-airflow                                              : Running sphinx. The output is hidden until an error occurs.
apache-airflow                                              : Finished docs building successfully
Documentation build is successful
root@bdc147c580ac:/opt/airflow# pip freeze |  grep astroid
astroid @ git+https://github.com/jacobtylerwalls/astroid.git@3df008431b1801e0b38896530481fbe93baf0317

@jacobtylerwalls
Copy link
Member

Nice!

(though some tests are failing for you :P )

yeah, I was hoping to get a reproducer without urllib3, but my effort to repro with just six failed...

potiuk added a commit to apache/airflow that referenced this issue Jul 21, 2022
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

(cherry picked from commit ee564ef)
@jacobtylerwalls
Copy link
Member

@potiuk:
With encouragement from @DanielNoord I found a more correct implementation and pushed it to #1714, so you may be interested to try testing it again.

@potiuk
Copy link
Author

potiuk commented Aug 2, 2022

Sorrry for the delay. Had to catch up with stuff :)

Yep. Installed astroid from tip of https://github.com/jacobtylerwalls/astroid/tree/namespace-path-crash and it also solves the problem:

image

leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Dec 7, 2022
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

(cherry picked from commit ee564ef9e57707ef07db1c3353a1406e47d8e3db)

GitOrigin-RevId: 06e4976aaf3236d06b7e6ec85a796f82718ddfcd
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jan 30, 2023
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

GitOrigin-RevId: ee564ef9e57707ef07db1c3353a1406e47d8e3db
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this issue Sep 12, 2024
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

(cherry picked from commit ee564ef9e57707ef07db1c3353a1406e47d8e3db)

GitOrigin-RevId: 06e4976aaf3236d06b7e6ec85a796f82718ddfcd
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 18, 2024
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

GitOrigin-RevId: ee564ef9e57707ef07db1c3353a1406e47d8e3db
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Nov 7, 2024
Astroid 2.12 released 9th of July breaks documentation building
with sphinx-autoapi.

Issue about it has been opened in
pylint-dev/astroid#1708

Until it is fixed, we should limit astroid.

GitOrigin-RevId: ee564ef9e57707ef07db1c3353a1406e47d8e3db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants