Skip to content

[False positive] py/unused-local-variable on SQLAlchemy model definition classes #11407

Open
@amotl

Description

Hi there,

thanks a stack for bringing LGTM to CodeQL. We used your kickstart template PR crate/crate-python#467 for making the transition happen on one of our Python repositories and wanted to report back about a potential false positive, after mitigating all other admonitions on our end before.

With kind regards,
Andreas.

Description of the false positive

py/unused-local-variable is raised on SQLAlchemy model definition classes, which are only defined, but not used.

Code samples or links to source code

class DummyTable(Base):
    __tablename__ = "t"
    pk = sa.Column(sa.String, primary_key=True)
    tags = sa.Column(ObjectArray)

Base.metadata.create_all()

URL to the alert on GitHub code scanning (optional)

Thoughts

I wonder if anything can be done about it, other than manually dismissing corresponding admonitions?

As far as we understand, CodeQL does not feature inline suppression comments/instructions, like what LGTM did with lgtm[py/import-and-import-from], right? (crate/crate-python@4397cc2e7)

Do you have any other suggestions on this matter?

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions