-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: False positive when used with typing (mypy) patterns #3979
Comments
This failed for me too: from typing import Optional
x: Optional[int] |
@ssbarnea thanks for your report. I can reproduce it. |
This seems to be related to #3951 |
@cdce8p thank you! I can confirm the bug is fixed. I can no longer reproduce it with current master branches of |
I have the same message with exactly this code in Python 3.8 is this intentional or a bug? pylint 2.12.2 |
I can reproduce the issue again with python 3.8. It seems like the issue can be reintroduced easily in astroid and we'd need tests there too ideally. |
The issue was indeed fixed, but only for Python 3.9+. |
I'm not entirely certain if related, but I'm having the same issue with from __future__ import annotations
from sqlalchemy import Column, DateTime, Integer, String
class Player(BaseModel):
__tablename__ = "player"
user_id = db.Column(db.String(8), primary_key=True)
name = db.Column(db.String(32), nullable=False)
# The biggest region code I found so far was "us/co/coloradosprings" at 21
country_code = db.Column(db.String(24))
score = db.Column(db.Integer, nullable=False)
score_details = db.Column(db.String())
last_update = db.Column(db.DateTime())
rank: Optional[int] = None
schedules = db.relationship("Schedule", back_populates="owner")
@overload
def __init__( # type: ignore
self,
user_id: str | Column[String],
name: str | Column[String],
country_code: Optional[str | Column[String]],
score: int | float | Column[Integer],
last_update: Optional[str | Column[DateTime]],
score_details: Optional[str | Column[String]] = ...,
rank: Optional[int] = ...
): ...
[...] |
@Avasam That shouldn't be an issue anymore. Please make sure to test the latest pylint release. Additionally, stringified annotations should be used (either |
Apparently even the master branch code does not yet play well with a common pattern used to add type hints. The linked example is not unique, the same pattern can be seen in many places.
While adding
# pylint: disable=unsubscriptable-object
can be used as a temporary workaround, it worth creating a bug as the more people will be adopting type hints, the more such problems we will face.Current behavior
Expected behavior
Pass the linting as the code below is correct.
pylint --version output
2.6.0 and master, on python 3.9
The text was updated successfully, but these errors were encountered: