I'm using sqlalchemy in combination with databases, databases[mysql] and aiomysql to provide async access to the database. Pycharm shows a warning when constructing sqlalchemy queries. See the following example:
from sqlalchemy import Column, Integer, String, Boolean, Table
users = Table(
"user",
metadata,
Column("id", Integer, primary_key=True, index=True),
Column("username", String(255), unique=True, index=True),
Column("email", String(255), unique=True, index=True),
Column("firstname", String(255), nullable=True),
Column("lastname", String(255), nullable=True),
Column("is_active", Boolean, default=True)
)
class User:
@classmethod
async def get(cls, username: str):
query = users.select().where(users.c.username == username)
user = await db.fetch_one(query)
return user
The warning Property 'c' cannot be read appears at the line constructing the query. According to the sqlalchemy documentation, this should be perfectly possible though.
Using the long form (users.columns.username) does not throw any warning.
Versions used:
- PyCharm 2020.2.3
- sqlalchemy 1.3.20
What is causing this warning, and is there a way go get rid of it?