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

E1136/E1137 false positives #10082

Open
bje- opened this issue Nov 15, 2024 · 1 comment
Open

E1136/E1137 false positives #10082

bje- opened this issue Nov 15, 2024 · 1 comment
Labels
Lib specific 💅 This affect the code from a particular library Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@bje-
Copy link

bje- commented Nov 15, 2024

Bug description

False positive E1136 and E1137 warnings from the following code:

"""docstring"""
import pandas as pd

class TraceLoad:
    """docstring"""
    csvdata = None

    def __init__(self, filename):
        """docstring"""
        cls = self.__class__
        cls.csvdata = pd.read_csv(filename, comment='#', sep=',')
        cls.csvdata['Date_Time'] = \
            pd.to_datetime(cls.csvdata['Date'] + ' ' + cls.csvdata['Time'])

Configuration

Command used

pylint example.py

Pylint output

************* Module example
example.py:12:8: E1137: 'cls.csvdata' does not support item assignment (unsupported-assignment-operation)
example.py:13:27: E1136: Value 'cls.csvdata' is unsubscriptable (unsubscriptable-object)
example.py:13:55: E1136: Value 'cls.csvdata' is unsubscriptable (unsubscriptable-object)

Expected behavior

No warnings.

Pylint version

pylint 3.3.1
astroid 3.3.5
Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]

OS / Environment

Ubuntu 24.04

Additional dependencies

pandas==2.2.3
@bje- bje- added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 15, 2024
@bje-
Copy link
Author

bje- commented Nov 16, 2024

I discovered that this only happens if csvdata is a class member. If I change the test case to just assign a local variable inside the __init__ function, the warnings go away.

@Pierre-Sassoulas Pierre-Sassoulas added the Lib specific 💅 This affect the code from a particular library label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lib specific 💅 This affect the code from a particular library Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

2 participants