-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
@property members defined in metaclasses of a base class are not correctly inferred #940
Milestone
Comments
Looks like this is caused by https://github.com/PyCQA/astroid/blob/f2b197a4f8af0ceeddf435747a5c937c8632872a/astroid/scoped_nodes.py#L2590-L2603. When we are inferring an attribute on a derived class then |
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 11, 2021
Ref pylint-dev#940. Would cause `Enum.__members__` to fail for enum classes defined as subclasses of `enum.Enum`
2 tasks
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 12, 2021
Ref pylint-dev#940. Would cause `Enum.__members__` to fail for enum classes defined as subclasses of `enum.Enum`
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 12, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 12, 2021
Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy).
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 12, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 12, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy).
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
May 11, 2021
Ref pylint-dev/astroid#940. These tests failed after fixing inference of Enum.__members__ due to unexpected "not-iterable" warnings raised. These warnings were not false-positives, as the test definition would have raised TypeError at runtime: .keys and .values on dict/mappingproxy are not properties, but methods.
4 tasks
Pierre-Sassoulas
pushed a commit
to pylint-dev/pylint
that referenced
this issue
May 11, 2021
* Fix Enum.__member__ regression tests Ref pylint-dev/astroid#940. These tests failed after fixing inference of Enum.__members__ due to unexpected "not-iterable" warnings raised. These warnings were not false-positives, as the test definition would have raised TypeError at runtime: .keys and .values on dict/mappingproxy are not properties, but methods. * Update _emit_no_member to ignore abstract properties * Update changelog and contributors
cdce8p
added a commit
to cdce8p/astroid
that referenced
this issue
May 11, 2021
…present Squashed commit of the following: commit b389805 Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 19:01:41 2021 +1000 Update changelog Ref pylint-dev#940 commit d93eb4a Author: Andrew Haigh <hello@nelf.in> Date: Mon May 10 20:54:22 2021 +1000 Fix inference of Enum.__members__ property for subclasses This updates the namedtuple/enum brain to add a dictionary for __members__ commit 611157e Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 18:49:18 2021 +1000 Fix inference of properties in a class context Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy). commit cc51d5b Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 18:44:34 2021 +1000 Add tests of failing property inference Ref pylint-dev#940
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy).
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
cdce8p
added a commit
to cdce8p/astroid
that referenced
this issue
May 12, 2021
…present Squashed commit of the following: commit 5dcd0ed Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue May 11 23:23:16 2021 +0000 [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci commit 39d359d Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 19:01:41 2021 +1000 Update changelog Ref pylint-dev#940 commit f3827bf Author: Andrew Haigh <hello@nelf.in> Date: Mon May 10 20:54:22 2021 +1000 Fix inference of Enum.__members__ property for subclasses This updates the namedtuple/enum brain to add a dictionary for __members__ commit 2dd4196 Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 18:49:18 2021 +1000 Fix inference of properties in a class context Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy). commit 92f03f2 Author: Andrew Haigh <hello@nelf.in> Date: Mon Apr 12 18:44:34 2021 +1000 Add tests of failing property inference Ref pylint-dev#940
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 13, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 13, 2021
Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy).
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 13, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 13, 2021
Ref pylint-dev#940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy).
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
May 14, 2021
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
May 14, 2021
4 tasks
cdce8p
pushed a commit
that referenced
this issue
May 15, 2021
#941) * Add tests of failing property inference Ref #940 * Fix inference of properties in a class context Ref #940. If we are accessing an attribute and it is found on type(A).__dict__ *and* it is a data descriptor, then we resolve that descriptor. For the case of inferring a property which is accessed as a class attribute, this equates to the property being defined on the metaclass (which may be anywhere in the class hierarchy). * Fix inference of Enum.__members__ property for subclasses Ref pylint-dev/pylint#3535. Ref pylint-dev/pylint#4358. This updates the namedtuple/enum brain to add a dictionary for __members__
cdce8p
pushed a commit
to pylint-dev/pylint
that referenced
this issue
May 30, 2021
* Add regression tests of issues related to Enum.__members__ Ref pylint-dev/astroid#940 * Add regression tests of properties on derived classes Ref pylint-dev/astroid#940
clrpackages
pushed a commit
to clearlinux-pkgs/pylint
that referenced
this issue
Jul 1, 2021
Aditya Gupta (1): Add ignore_signatures to similarity checker (#4474) Andrew Haigh (6): Update regression tests for pylint-dev/astroid#940 (#4466) Add regression tests of instance attribute inference on builtins.object (#4348) Add regression tests of inference of implicit None return (#4428) Additional regression tests for pylint-dev/astroid#940 (#4473) Add regression tests for Enum.name and .value inference (#4558) Add regression test from #2306 (#4570) David Liu (1): Add list literal check to using-constant-test. (#4502) Dr. Nick (1): Add --fail-on option (#4227) (#4398) DudeNr33 (6): Issue 4430 false positive consider-using-with R1732 (#4453) Consider using with no assign (#4476) Fix improperly formatted bullet points that span multiple lines Issue #3747 fix example regex for snakeCase naming style. Omit 'checker' in verbatim name of ``ConfusingConsecutiveElifChecker`` as it renders as "Confusing-Elif-Checker Checker" Issue #4541: add ``ignore-paths`` option to example pylintrc file. Fabian Damken (1): Add `ignore-paths` to match against the full path. (#4516) Jacob Walls (1): Fix errors in block disables paragraph in User Guide (#4489) Konstantina Saketou (3): Customize arguments-differ error messages (#4422) Create new error arguments-renamed (#4467) Add test cases to unused-variable message (#4540) Lorena B (1): Remove docs and code associated with the removed W0623 (redefine-in-handler) checker (#4543) Marc Mueller (47): Fix too-many-ancestors Fix broken tests (#4450) Fix changelog (#4442) Remove type check from arguments-differ (#4456) Change rebase-strategy dependabot (#4462) Tox - update pre-commit version (#4463) Fix additional test case Fix enum no-member Fix tests/test_func Add py310 as tox env Add sys.version_info guard to import-error (#4468) Workflow improvements (#4506) Improve build config (#4512) Add regression test for no-member with generic base class (#4471) Fix false-positive assigning-non-slot with typing.Generic base (#4522) Add new checker consider-using-namedtuple (#4517) Add new checker invalid-all-format Update name for consider-using-namedtuple to include dataclass (#4536) Bump pyupgrade to v2.19.1 (#4547) Improve traceback for pytest runs Add regression test for Pattern Matching 3.10 (#4550) Clarify documentation typing extension Update explanation Add additional documenation for typing extension Add new checker consider-using-tuple-iterator Fix existing code Fix existing tests Change to consider-using-tuple Move to new extension CodeStyleChecker Revert "Fix existing tests" Improve documentation Moved typing extension tests Renamed code_style extension test Add note to CodeStyleChecker Move remaining extension fixtures Documentation Move consider-using-namedtuple-or-dataclass to CodeStyle extension Documentation Add exclude_lines coverage (#4566) Fix error with slice as subscript for dict Update pre-commit-config Add additional typing requirements Add global mypy config Remove deprecated astroid.Ellipsis node (#4567) Remove deprecated astroid.Index and astroid.ExtSlice nodes (#4568) Recognize cached_property as property (#4594) Bump cache version Mark Byrne (1): Add type annotations to pyreverse (#4551) Markus Siebenhaar (1): Handle floats when parsing pyproject.toml (#4518) (#4520) Matus Valo (11): Add support for checking deprecated class arguments. (#4425) Add deprecated methods, classes and arguments to stdlib checker (#4424) warn deprecated x argument of int(), bool(), float() in all python versions (#4435) Add Deprecated Class unittests (#4448) Moved stdlib module deprecation from imports checker to stdlib checker (#4454) Added deprecated decorators check (#4513) Added support for deprecated method alias Updated whatsnew and changelog Fixed failing unittests Added various deprecated functions/methods for python 3.10, 3.7, 3.6 and 3.3 Updated Changelog and whatsnew Peter Kolbus (1): Fix issues with Python 3.6.0 (#4446) Pierre Sassoulas (51): Fix link to the logo in README.rst Logo visible in readme using RST syntax Revert "Logo visible in readme using RST syntax" Fix retrocompatbility of numversion Add pre-commit CI in continuous integration (#4423) Add python 3.10 dev in the CI Fix test failing because python 10 got better Strangely a new legacy test case appeared ? Add security.md for Tidelift coordinated disclosure plan (#4493) Require astroid 2.5.7 Fix invalid value returned in len Fix warning expected on logger class created from renamed import Upgrade release.md following the decision to pin astroid Add the changelog for 2.8.3 Add typing in pylint.messages Refactor register_message_definition to prevent circular import Upgrade to astroid 2.5.8 Add documentation in order to prevent error in the future Add test case from issue #119 for easier resolution Add handle_message in BaseReporter and add typing Add unit tests for OutputLine Remove dead code, always return the confidence Use a NamedTuple from typing directly Refactor the json reporter so handle message work the same way Special case for python < 3.8 with worse AST handling Remove appveyor.yml replaced by Github actions Upgrade astroid to 2.6.0-dev0 (#4581) Add a release step in Github Actions Add tbump script for bumbing version Migration from setuptools_scm to tbump Add alias for bots in copyrite aliases Bump pylint to 2.9.0-dev1, update changelog Fix update a functional test with no expected output No crash on bad plugin provided in configuration file Add a test for too-many-statements when modified by configuration Upgrade astroid to 2.6.0 (#4602) Add code analysis provided by GitHub(#4605) Fix a crash when a test function is decorated with ``@pytest.fixture`` (#4613) Add regression tests for issue #2913 Add a '__repr__' function in Docstring Fix useless-type-doc false positive when args exist in the docstring Make a smarter check to avoid 'useless-type-doc' false positive Fix a syntax error in unittest_deprecated.py test code Add a functional test for deprecated_methods Add a regression test following issue #4610 Upgrade astroid to 2.6.1 Upgrade the release script using what was done in astroid Upgrade the copyrite alias with Mark Bryne Normalize the changelog and fix old oversight Upgrade documentation for the new release script Bump pylint to 2.9.0, update changelog, add python 3.10 to package meta Sergei Lebedev (1): VariableChecker now accounts for attribute lookups in type comments (#4604) Stanislav Levin (1): tests: Sort for comparison in test_expand_modules dependabot[bot] (25): Bump pyupgrade from 2.11.0 to 2.14.0 (#4432) Bump black from 21.4b0 to 21.4b2 (#4433) Bump python-docs-theme from 2020.12 to 2021.5 (#4460) Bump sphinx from 3.5.4 to 4.0.0 (#4461) Bump flake8 from 3.9.0 to 3.9.2 (#4459) Bump black from 21.4b2 to 21.5b0 (#4458) Bump pyupgrade from 2.14.0 to 2.15.0 (#4457) Update pytest-cov requirement from ~=2.11 to ~=2.12 (#4479) Bump sphinx from 4.0.0 to 4.0.1 (#4478) Bump pyupgrade from 2.15.0 to 2.16.0 (#4477) Update pre-commit requirement from ~=2.12 to ~=2.13 (#4495) Bump pyupgrade from 2.16.0 to 2.18.1 (#4496) Bump sphinx from 4.0.1 to 4.0.2 (#4494) Bump actions/cache from 2.1.5 to 2.1.6 Update coveralls requirement from ~=3.0 to ~=3.1 Bump black from 21.5b1 to 21.5b2 Bump black from 21.5b2 to 21.6b0 (#4572) Bump mypy from 0.812 to 0.902 Bump types-toml from 0.1.2 to 0.1.3 (#4599) Bump isort from 5.8.0 to 5.9.0 (#4598) Bump actions/upload-artifact from 2.2.3 to 2.2.4 (#4596) Bump actions/download-artifact from 2.0.9 to 2.0.10 (#4595) Update pytest-xdist requirement from ~=2.2 to ~=2.3 (#4597) Bump types-pkg-resources from 0.1.2 to 0.1.3 (#4600) Bump mypy from 0.902 to 0.910 (#4621) pre-commit-ci[bot] (9): [pre-commit.ci] pre-commit autoupdate (#4438) [pre-commit.ci] pre-commit autoupdate (#4465) [pre-commit.ci] pre-commit autoupdate (#4481) [pre-commit.ci] pre-commit autoupdate (#4501) [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate (#4601) [pre-commit.ci] pre-commit autoupdate (#4622) ruro (1): Multiple `output-format` support (#4492) victor (1): Add new warning ``deprecated-class`` #4388 (#4419) yushao2 (13): Implemented new check consider-using-dict-items (#4445) Removed redundant logic from consider-using-dict-items (#4486) Implemented new check use-maxsplit-arg (#4469) Implemented new check unnecessary-dict-index-lookup (#4485) Implemented new check consider-using-from-import (#4491) Implemented ``unused-private-member`` checker (#4504) Added suggestion in helptext for ``unnecessary-comprehension`` checker (#4500) Fixed false-positive on ``unused-private-member`` (#4507) Fixed minor doc formatting (#4511) Fixed false negative of consider-using-enumerate on attributes (#4508) Implemented new checker invalid-class-object (#4510) Minor refactoring of ``tests/functional/a`` directory (#4515) Implemented new checker await-outside-async (#4514)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ref #927 (comment)
Inference works on the parent class but not the child in the following example:
The text was updated successfully, but these errors were encountered: