Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tamird opened this issue Jun 28, 2024 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@tamird
Copy link

tamird commented Jun 28, 2024

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

@tamird tamird added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant