pylint
pylint copied to clipboard
Incorrect E1101 (no-member) using SQLAlchemy @hybrid_property
Steps to reproduce
- Reproducing code wrong_no_member.txt
from sqlalchemy import Column, Boolean
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.schema import PrimaryKeyConstraint
Base = declarative_base()
class Table(Base):
__tablename__ = 'table'
__table_args__ = (PrimaryKeyConstraint('column1'),)
_column1 = Column('column1', Boolean)
column2 = Column('column2', Boolean)
@hybrid_property
def column1(self):
return self._column1
@column1.setter
def column1(self, column1):
self._column1 = column1
Table.column1.op('*')
Table.column2.op('*')
- Just run as
pylint wrong_no_member.py
Current behavior
Complains about column1, wrong_no_member.py:24:0: E1101: Method 'column1' has no 'op' member (no-member)
Expected behavior
No errors
pylint --version output
$ pylint --version
pylint 2.4.4
astroid 2.3.3
Python 3.6.6 (default, May 14 2019, 11:57:55)
[GCC 7.4.0]
There's a few other issues in this repo and the astroid repo about various issues with properties, https://github.com/PyCQA/pylint/issues/1061 is probably the closest.
Even with regular columns, not sure if I should create a difference issue or if this belongs here.
class Player(BaseModel):
__tablename__ = "player"
country_code = db.Column(db.String(24))
[...]
Player.country_code.like(f"{country_code}/%")
