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

no-member for Generic class with new astroid 2.15.7 #9069

Closed
altendky opened this issue Sep 25, 2023 · 2 comments
Closed

no-member for Generic class with new astroid 2.15.7 #9069

altendky opened this issue Sep 25, 2023 · 2 comments
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@altendky
Copy link

altendky commented Sep 25, 2023

Bug description

I get a `no-member` error for attributes of a generic dataclass when running with the new astroid 2.15.7.  This is true for both pylint 2.17.5 and the new pylint 2.17.6.


$ cat p.py
# pylint: disable=missing-module-docstring invalid-name missing-class-docstring
from dataclasses import dataclass
from typing import Generic, TypeVar


T_Inner = TypeVar("T_Inner", bound="Inner")


@dataclass
class Inner:
    inner_attribute: str


@dataclass
class Outer(Generic[T_Inner]):
    inner: T_Inner


x = Outer(inner=Inner(inner_attribute="magic xylophone"))
print(x.inner.inner_attribute)

Configuration

No response

Command used

$ python3.11 --version --version
Python 3.11.2 (main, Mar  5 2023, 21:14:41) [GCC 11.3.0]
$ rm -rf venv
$ python3.11 -m venv venv && venv/bin/pip install pylint==2.17.6 astroid==2.15.7
Collecting pylint==2.17.6
  Using cached pylint-2.17.6-py3-none-any.whl (537 kB)
Collecting astroid==2.15.7
  Using cached astroid-2.15.7-py3-none-any.whl (278 kB)
Collecting platformdirs>=2.2.0
  Using cached platformdirs-3.10.0-py3-none-any.whl (17 kB)
Collecting isort<6,>=4.2.5
  Using cached isort-5.12.0-py3-none-any.whl (91 kB)
Collecting mccabe<0.8,>=0.6
  Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Collecting tomlkit>=0.10.1
  Using cached tomlkit-0.12.1-py3-none-any.whl (37 kB)
Collecting dill>=0.3.6
  Using cached dill-0.3.7-py3-none-any.whl (115 kB)
Collecting lazy-object-proxy>=1.4.0
  Using cached lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (64 kB)
Collecting wrapt<2,>=1.14
  Using cached wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (78 kB)
Installing collected packages: wrapt, tomlkit, platformdirs, mccabe, lazy-object-proxy, isort, dill, astroid, pylint
Successfully installed astroid-2.15.7 dill-0.3.7 isort-5.12.0 lazy-object-proxy-1.9.0 mccabe-0.7.0 platformdirs-3.10.0 pylint-2.17.6 tomlkit-0.12.1 wrapt-1.15.0

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: /home/altendky/tmp/blue/venv/bin/python3.11 -m pip install --upgrade pip
$ venv/bin/pylint p.py
************* Module p
p.py:20:6: E1101: Instance of 'T_Inner' has no 'inner_attribute' member (no-member)

-------------------------------------------------------------------
Your code has been rated at 4.44/10 (previous run: 10.00/10, -5.56)
$ rm -rf venv
$ python3.11 -m venv venv && venv/bin/pip install pylint==2.17.5 astroid==2.15.7
Collecting pylint==2.17.5
  Using cached pylint-2.17.5-py3-none-any.whl (536 kB)
Collecting astroid==2.15.7
  Using cached astroid-2.15.7-py3-none-any.whl (278 kB)
Collecting platformdirs>=2.2.0
  Using cached platformdirs-3.10.0-py3-none-any.whl (17 kB)
Collecting isort<6,>=4.2.5
  Using cached isort-5.12.0-py3-none-any.whl (91 kB)
Collecting mccabe<0.8,>=0.6
  Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Collecting tomlkit>=0.10.1
  Using cached tomlkit-0.12.1-py3-none-any.whl (37 kB)
Collecting dill>=0.3.6
  Using cached dill-0.3.7-py3-none-any.whl (115 kB)
Collecting lazy-object-proxy>=1.4.0
  Using cached lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (64 kB)
Collecting wrapt<2,>=1.14
  Using cached wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (78 kB)
Installing collected packages: wrapt, tomlkit, platformdirs, mccabe, lazy-object-proxy, isort, dill, astroid, pylint
Successfully installed astroid-2.15.7 dill-0.3.7 isort-5.12.0 lazy-object-proxy-1.9.0 mccabe-0.7.0 platformdirs-3.10.0 pylint-2.17.5 tomlkit-0.12.1 wrapt-1.15.0

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: /home/altendky/tmp/blue/venv/bin/python3.11 -m pip install --upgrade pip
$ venv/bin/pylint p.py
************* Module p
p.py:20:6: E1101: Instance of 'T_Inner' has no 'inner_attribute' member (no-member)

------------------------------------------------------------------
Your code has been rated at 4.44/10 (previous run: 4.44/10, +0.00)

Pylint output

************* Module p
p.py:20:6: E1101: Instance of 'T_Inner' has no 'inner_attribute' member (no-member)

------------------------------------------------------------------
Your code has been rated at 4.44/10 (previous run: 4.44/10, +0.00)

Expected behavior

$ rm -rf venv
$ python3.11 -m venv venv && venv/bin/pip install pylint==2.17.5 astroid==2.15.6
Collecting pylint==2.17.5
  Using cached pylint-2.17.5-py3-none-any.whl (536 kB)
Collecting astroid==2.15.6
  Using cached astroid-2.15.6-py3-none-any.whl (278 kB)
Collecting platformdirs>=2.2.0
  Using cached platformdirs-3.10.0-py3-none-any.whl (17 kB)
Collecting isort<6,>=4.2.5
  Using cached isort-5.12.0-py3-none-any.whl (91 kB)
Collecting mccabe<0.8,>=0.6
  Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Collecting tomlkit>=0.10.1
  Using cached tomlkit-0.12.1-py3-none-any.whl (37 kB)
Collecting dill>=0.3.6
  Using cached dill-0.3.7-py3-none-any.whl (115 kB)
Collecting lazy-object-proxy>=1.4.0
  Using cached lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (64 kB)
Collecting wrapt<2,>=1.14
  Using cached wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (78 kB)
Installing collected packages: wrapt, tomlkit, platformdirs, mccabe, lazy-object-proxy, isort, dill, astroid, pylint
Successfully installed astroid-2.15.6 dill-0.3.7 isort-5.12.0 lazy-object-proxy-1.9.0 mccabe-0.7.0 platformdirs-3.10.0 pylint-2.17.5 tomlkit-0.12.1 wrapt-1.15.0

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: /home/altendky/tmp/blue/venv/bin/python3.11 -m pip install --upgrade pip
$ venv/bin/pylint p.py

-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 4.44/10, +5.56)

Pylint version

$ venv/bin/pylint --version
pylint 2.17.6
astroid 2.15.7
Python 3.11.2 (main, Mar  5 2023, 21:14:41) [GCC 11.3.0]
$ venv/bin/pylint --version
pylint 2.17.5
astroid 2.15.7
Python 3.11.2 (main, Mar  5 2023, 21:14:41) [GCC 11.3.0]

OS / Environment

$ uname -a
Linux p1 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Additional dependencies

No response

@altendky altendky added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 25, 2023
altendky added a commit to Chia-Network/chia-blockchain that referenced this issue Sep 25, 2023
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 25, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue. I can reproduce on main (3.0.0b0)

@jacobtylerwalls
Copy link
Member

This is probably the same issue as pylint-dev/astroid#2305, but keeping this open so we close it with a regression test in pylint.

@jacobtylerwalls jacobtylerwalls added this to the 2.17.7 milestone Sep 25, 2023
AmineKhaldi pushed a commit to AmineKhaldi/chia-blockchain that referenced this issue Sep 25, 2023
wallentx pushed a commit to Chia-Network/chia-blockchain that referenced this issue Sep 25, 2023
mbyrnepr2 added a commit to mbyrnepr2/astroid that referenced this issue Sep 25, 2023
- Raise an `InferenceError` when there is a `SyntaxError` due to an invalid `TypeVar` name.

Closes pylint-dev#2305
Closes pylint-dev/pylint#9069
wallentx pushed a commit to Chia-Network/chia-blockchain that referenced this issue Sep 25, 2023
mbyrnepr2 added a commit to mbyrnepr2/astroid that referenced this issue Sep 25, 2023
- Raise an `InferenceError` when there is a `SyntaxError` due to an invalid `TypeVar` name.

Closes pylint-dev#2305
Closes pylint-dev/pylint#9069
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Sep 25, 2023
github-actions bot pushed a commit to pylint-dev/astroid that referenced this issue Sep 26, 2023
Fix a regression in 2.15.7 for ``unsubscriptable-object``.

Raise an `InferenceError` when there is a `SyntaxError` due to an invalid `TypeVar` name.
This reverts commit 89dfb48.

Closes #2305
Closes pylint-dev/pylint#9069

(cherry picked from commit 1f0f2f8)
jacobtylerwalls pushed a commit to pylint-dev/astroid that referenced this issue Sep 26, 2023
Fix a regression in 2.15.7 for ``unsubscriptable-object``.

Raise an `InferenceError` when there is a `SyntaxError` due to an invalid `TypeVar` name.
This reverts commit 89dfb48.

Closes #2305
Closes pylint-dev/pylint#9069

(cherry picked from commit 1f0f2f8)

Co-authored-by: Mark Byrne <[email protected]>
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Sep 26, 2023
Pierre-Sassoulas pushed a commit to mbyrnepr2/pylint that referenced this issue Sep 27, 2023
jacobtylerwalls pushed a commit that referenced this issue Sep 30, 2023
jacobtylerwalls pushed a commit that referenced this issue Sep 30, 2023
Refs #9069
Refs pylint-dev/astroid#2305

(cherry picked from commit 04f7b3d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

3 participants