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

Update astroid to 2.12 #7153

Merged
merged 1 commit into from
Jul 13, 2022
Merged

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Jul 9, 2022

Type of Changes

Type
🔨 Refactoring

Fixes #5935
(among other issues to be closed shortly with regression tests in separate PRs, see label "Needs astroid update")

The main change relevant now is astroid's better support for detecting namespace packages.

@jacobtylerwalls jacobtylerwalls added Astroid Related to astroid Maintenance Discussion or action around maintaining pylint or the dev workflow labels Jul 9, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.15.0 milestone Jul 9, 2022
@github-actions

This comment has been minimized.

@coveralls
Copy link

coveralls commented Jul 9, 2022

Pull Request Test Coverage Report for Build 2663062215

  • 9 of 9 (100.0%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 95.371%

Files with Coverage Reduction New Missed Lines %
pylint/checkers/classes/class_checker.py 1 94.82%
pylint/lint/pylinter.py 1 94.74%
pylint/reporters/text.py 1 85.07%
pylint/lint/expand_modules.py 2 94.74%
Totals Coverage Status
Change from base Build 2662295713: -0.02%
Covered Lines: 16792
Relevant Lines: 17607

💛 - Coveralls

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jacobtylerwalls

This comment was marked as resolved.

@jacobtylerwalls
Copy link
Member Author

@Pierre-Sassoulas It's more clear to me now: I think it's a packaging problem with https://github.com/Pierre-Sassoulas/contributors-txt, which installs a tests directory in site-packages.

>>> import tests
>>> tests
<module 'tests' from '/Users/.../new/lib/python3.10/site-packages/tests/__init__.py'>

The reason we don't have failures on Linux/MacOS is that those install requirements_test.txt with contributors-txt, and the pypy/windows workflows install requirements_test_min.txt without it. I'll push changes to bless the windows/pypy results and then the failures will occur on Linux/MacOS until fixing the packaging issue.

Would you be willing to look into the packaging issue?

@jacobtylerwalls jacobtylerwalls added the Blocked 🚧 Blocked by a particular issue label Jul 10, 2022
@github-actions

This comment has been minimized.

@Pierre-Sassoulas
Copy link
Member

Would you be willing to look into the packaging issue?

Sure, I'm on it!

doc/whatsnew/2/2.15/index.rst Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
requirements_test_min.txt Outdated Show resolved Hide resolved
@Pierre-Sassoulas Pierre-Sassoulas changed the title Update astroid to 2.12.0 Update astroid to 2.12 Jul 10, 2022
@github-actions

This comment has been minimized.

@Pierre-Sassoulas
Copy link
Member

I released a new version of contributors-txt without tests directory. But I think that it's probably better if we patch the sys.path in the current test instead of changing the expected result. (Might be a good thing if we do it in another merge request prior to upgrading astroid and also remove our custom patching function in favor of the current pytest way to do it)

@jacobtylerwalls
Copy link
Member Author

I wondered about that. Would you be willing to start that PR?

@Pierre-Sassoulas
Copy link
Member

Yeap, let me try something :)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jacobtylerwalls
Copy link
Member Author

jacobtylerwalls commented Jul 10, 2022

TODO:

@github-actions

This comment has been minimized.

@AdamWill
Copy link
Contributor

AdamWill commented Jul 11, 2022

An interesting thing about the cases where we now get a tests. prefix on some strings: this changes depending on where you run the tests from. If you run them from outside the top level of the source tree - e.g. go up one level and run something like pytest pylint/tests - the tests. prefix goes away again (and the tests fail if they've been patched to expect it).

Not sure how much you care about this, but it's there. :D I found it while tinkering about to fix a different problem with running the tests as part of a package build (astroid doesn't like it if you run the tests from the top level of the source tarball but with PYTHONPATH=/path/to/installroot to try and run the tests using the 'installed' files, rather than the files from the tarball).

@github-actions

This comment has been minimized.

@jacobtylerwalls
Copy link
Member Author

An interesting thing about the cases where we now get a tests. prefix on some strings: this changes depending on where you run the tests from.

Very true. And because that's true, we could probably avoid fiddling with the expected results and just change cwd to tests/data instead (as some other tests do). Thanks for the inspiration!

@DudeNr33 as a pyreverse expert does that sound like a good plan? Elsewhere you suggested (for new tests) what I think is a good practice of using dynamically generated files.

@jacobtylerwalls jacobtylerwalls removed the Blocked 🚧 Blocked by a particular issue label Jul 12, 2022
@jacobtylerwalls jacobtylerwalls marked this pull request as ready for review July 12, 2022 11:57
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@@ -1,2 +1,2 @@
R: 1: Cyclic import (input.func_w0401_package.all_the_things -> input.func_w0401_package.thing2)
R: 1: Cyclic import (tests.input.func_w0401_package.all_the_things -> tests.input.func_w0401_package.thing2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same thing as the pyreverse stuff, I think - should we change to the cwd-based fix here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cwd-based fix in 6fa6e74

@DudeNr33
Copy link
Collaborator

An interesting thing about the cases where we now get a tests. prefix on some strings: this changes depending on where you run the tests from.

Very true. And because that's true, we could probably avoid fiddling with the expected results and just change cwd to tests/data instead (as some other tests do). Thanks for the inspiration!

@DudeNr33 as a pyreverse expert does that sound like a good plan? Elsewhere you suggested (for new tests) what I think is a good practice of using dynamically generated files.

Yes, that's fine for me! In reality I'd also expect the user to first cd into the root directory for his project.

Copy link
Collaborator

@DudeNr33 DudeNr33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have an open question why two of the pyreverse tests are now marked as xfail - but as we have a lot of other tests for pyreverse I think this should not be a blocker, I'm just curious. 😊

Comment on lines 27 to 28
As of version 2.15, ``pylint`` will also discover namespace packages but there are some edge
cases still under development (where you might still find ``--recursive=y`` useful).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this sentence. From the wording it sounds like it is (in most cases) no longer necessary to use --recursive=y, yet the preceding sentences all describe the usage with it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved comprehensibility in 63d654c

self, HANDLER: DiadefsHandler, PROJECT: Project
) -> None:
# https://github.com/PyCQA/pylint/issues/2763
@pytest.mark.xfail
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried this myself yet, but why is the xfail necessary here?
The linked issue is about working without __init__.py files - but the tests/data has an __init__.py file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible I didn't understand the issue. (A good sign I should remove the comment!) I thought since tests doesn't have an __init__.py it's possible it would explain why the analysis of tests/data was not entirely correct. But maybe it's a manifestation of something else. I can remove the comment.

The failure is that only the last member of _should_rels is found, not all 5.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed comments in 916e556

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

Prevent `unused-import` for `six.with_metaclass`

Update `contributors-txt` to 0.9.0

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
@jacobtylerwalls
Copy link
Member Author

Thanks to all for helping push this over the line!

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this pull request Jul 13, 2022
str's repr is the string, and you don't need a string call in a fstring.

Follow-up to pylint-dev#7153 (comment)
@github-actions
Copy link
Contributor

🤖 Effect of this PR on checked open source code: 🤖

Effect on django:
The following messages are now emitted:

  1. invalid-name:
    Attribute name "Meta" doesn't conform to '[a-z_][a-z0-9_]{2,}$' pattern
    https://github.com/django/django/blob/main/django/db/models/base.py#L360
  2. no-value-for-parameter:
    No value for argument 'cls' in classmethod call
    https://github.com/django/django/blob/main/django/utils/deconstruct.py#L17

The following messages are no longer emitted:

  1. no-member:
    Instance of 'BaseManager' has no '_constructor_args' member
    https://github.com/django/django/blob/main/django/db/models/manager.py#L75
  2. no-member:
    Instance of 'BaseManager' has no '_constructor_args' member
    https://github.com/django/django/blob/main/django/db/models/manager.py#L76
  3. no-member:
    Instance of 'BaseManager' has no '_constructor_args' member
    https://github.com/django/django/blob/main/django/db/models/manager.py#L169

Effect on pandas:
The following messages are now emitted:

  1. redefined-variable-type:
    Redefinition of columns type from pandas.core.indexes.range.RangeIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/internals/construction.py#L860
  2. redefined-variable-type:
    Redefinition of new_target type from pandas.core.indexes.category.CategoricalIndex to pandas.core.indexes.base.Index
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/indexes/category.py#L455

The following messages are no longer emitted:

  1. redefined-variable-type:
    Redefinition of index type from pandas.core.indexes.base.Index to pandas.core.indexes.range.RangeIndex
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/series.py#L456
  2. redefined-variable-type:
    Redefinition of columns type from pandas.core.indexes.base.Index to pandas.core.indexes.range.RangeIndex
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/internals/construction.py#L850
  3. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/floating.py#L141
  4. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/floating.py#L148
  5. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L160
  6. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L167
  7. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L174
  8. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L181
  9. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L188
  10. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L195
  11. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L202
  12. empty-docstring:
    Empty class docstring
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/arrays/integer.py#L209
  13. redefined-variable-type:
    Redefinition of new_target type from pandas.core.indexes.base.Index to pandas.core.indexes.category.CategoricalIndex
    https://github.com/pandas-dev/pandas/blob/main/pandas/core/indexes/category.py#L442

Effect on pytest:
The following messages are now emitted:

  1. consider-using-dict-items:
    Consider iterating with .items()
    https://github.com/pytest-dev/pytest/blob/main/src/_pytest/reports.py#L513
  2. redefined-variable-type:
    Redefinition of ret type from str to _pytest.config.ExitCode
    https://github.com/pytest-dev/pytest/blob/main/src/_pytest/pytester.py#L1145
  3. redefined-variable-type:
    Redefinition of ret type from int to _pytest.config.ExitCode
    https://github.com/pytest-dev/pytest/blob/main/src/_pytest/pytester.py#L1429
  4. no-name-in-module:
    No name 'PytestReturnNotNoneWarning' in module '_pytest.warning_types'
    https://github.com/pytest-dev/pytest/blob/main/src/_pytest/python.py#L80
  5. redefined-variable-type:
    Redefinition of importhook type from _distutils_hack.DistutilsMetaFinder to _pytest.assertion.DummyRewriteHook
    https://github.com/pytest-dev/pytest/blob/main/src/_pytest/assertion/__init__.py#L69

Effect on sentry:
The following messages are now emitted:

  1. redefined-variable-type:
    Redefinition of culprit type from str to list
    https://github.com/getsentry/sentry/blob/master/src/sentry/culprit.py#L38
  2. consider-iterating-dictionary:
    Consider iterating the dictionary directly instead of calling .keys()
    https://github.com/getsentry/sentry/blob/master/src/sentry/web/frontend/error_page_embed.py#L138
  3. no-member:
    Instance of 'module' has no 'file' member
    https://github.com/getsentry/sentry/blob/master/src/sentry/utils/distutils/commands/base.py#L37

The following messages are no longer emitted:

  1. unused-import:
    Unused ActorTuple imported from sentry.models
    https://github.com/getsentry/sentry/blob/master/src/sentry/models/projectownership.py#L9
  2. not-callable:
    fmt is not callable
    https://github.com/getsentry/sentry/blob/master/src/sentry/utils/snuba.py#L1316
  3. no-member:
    Instance of 'str' has no 'objects' member
    https://github.com/getsentry/sentry/blob/master/src/sentry/utils/snuba.py#L1316
  4. redefined-variable-type:
    Redefinition of initials type from str to django.utils.safestring.SafeString
    https://github.com/getsentry/sentry/blob/master/src/sentry/utils/avatar.py#L77

This comment was generated for commit 2b4123a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astroid Related to astroid Maintenance Discussion or action around maintaining pylint or the dev workflow
Projects
None yet
6 participants