Pylint: False positive "no-member" for SQLAlchemy "Session" object with pylint 2.5.2

Created on 11 May 2020  路  8Comments  路  Source: PyCQA/pylint

Steps to reproduce

  1. create a file containing the following code (e.g. call it test.py):
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

def spam(url):
    engine = create_engine(url)
    session = sessionmaker(bind=engine)()
    query = session.query()
  1. create a new virtualenv containing the following packages:
  2. pylint==2.5.2 (latest)
  3. SQLAlchemy==1.3.16 (latest - locally I have it pinned to 1.3.13, though (1) the interface does not have changed and (2) I get the same error for both versions)
  4. call
pylint -E test.py

Current behavior

************* Module test
test.py:7:12: E1101: Instance of 'Session' has no 'query' member (no-member)

Expected behavior

With pylint 2.4.4, you don't get this error.

pylint --version output

pylint 2.5.2
astroid 2.4.1
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
astroid brain bug

Most helpful comment

It seems that this bug has been fixed in astroid master branch thanks to the addition of a brain dedicated to SQLAlchemy. (Thanks @sscherfke PyCQA/astroid#787)
It will be available as soon as the 2.5 version of astroid聽will be released.
I close this issue.

All 8 comments

I confirm this regression with my code and the same configuration

Ditto for me as well. We had to revert to 2.4.4. We also git errors regarding __table___ not being a member of our table classes with the new version.

Same issue here. Additionally, accessing methods I add to the Base class (Base = declarative_base(engine)) give no-member when accessed through a child class:

Base.all = classmethod(all)
Base.by_id = classmethod(single_lookup(by_id))
[...]

These were not no-member'd in version 2.4.4.

There are also no-members being given for backref fields added by sqlalchemy.orm.relationship, and a multitude of other cases. Can also confirm @Syntactical01's issue with __table__.

same issue for me ..

Exactly same issue for me. Any clue when this will be fixed?

Bump: similar behavior on 2.3.1

Still an issue on 2.6.0

It seems that this bug has been fixed in astroid master branch thanks to the addition of a brain dedicated to SQLAlchemy. (Thanks @sscherfke PyCQA/astroid#787)
It will be available as soon as the 2.5 version of astroid聽will be released.
I close this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamtheturtle picture adamtheturtle  路  3Comments

Hubro picture Hubro  路  3Comments

PCManticore picture PCManticore  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

DevynCJohnson picture DevynCJohnson  路  3Comments