Pylint: func.max is not callable
Asked Answered
A

2

8

In my python code, I import func...

from sqlalchemy.sql.expression import func

Then, during my code I select data from a database table...

select(func.max(MyTable.my_datetime))

...where my_datetime is a DateTime data type...

from sqlalchemy.types import DateTime

my_datetime = Column('my_datetime', DateTime)

The code runs OK, but in the vscode editor I am getting the following error...

func.max is not callable Pylint(E1102:not-callable)

I don't want to ignore this if there is a genuine concern behind this Pylint error.

Should I be concerned by this error or can I safely ignore it?

Akins answered 20/3, 2023 at 10:52 Comment(1)
See github.com/sqlalchemy/sqlalchemy/issues/9189Gesture
B
9

The Pylint error you have (func.max is not callable Pylint(E1102:not-callable)) is a false positive and you can ignore it in your case.

Pylint is flagging func.max not callable because it can't analyze the func object statically and determine that it has a max method.

You can use

func: Callable

after importing .

Barbie answered 20/3, 2023 at 10:54 Comment(1)
This works, although I had to add ` # type: ignore[no-redef]` for mypy. But I don't understand how defining a type on func says anything about func.max()?Templar
W
3

You can add the following comment in a line before the line where you get the error.

# pylint: disable=not-callable
Willie answered 15/10, 2023 at 8:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.