pylint-dev/pylint

no-value-for-parameter false positive with sqlalchemy.ext.hybrid.hybrid_method

Opened this issue · 0 comments

tamird commented

Bug description

Taking an example from the sqlalchemy.ext.hybrid.hybrid_method docs:

from __future__ import annotations

from sqlalchemy.ext.hybrid import hybrid_method
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column


class Base(DeclarativeBase):
    pass

class Interval(Base):
    __tablename__ = 'interval'

    id: Mapped[int] = mapped_column(primary_key=True)
    start: Mapped[int]
    end: Mapped[int]

    def __init__(self, start: int, end: int):
        self.start = start
        self.end = end

    @hybrid_property
    def length(self) -> int:
        return self.end - self.start

Interval.length() # <--- false positive here

Interval.length is both a class method and an instance method, and can be called as a class method when building SQL queries. pylint reports no-value-for-parameter on this usage.

Configuration

No response

Command used

pylint foo.py

Pylint output

E1120: No value for argument 'self' in unbound method call (no-value-for-parameter)

Expected behavior

No error.

Pylint version

pylint 3.2.3
astroid 3.2.2
Python 3.12.4 (main, Jun 24 2024, 06:23:58) [Clang 15.0.0 (clang-1500.3.9.4)]

OS / Environment

No response

Additional dependencies

No response