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

Add SQLAlchemy model definition class to complete the implementation #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions unused-local-variable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Evaluate CodeQL scan false positive with `py/unused-local-variable`.

`DummyTable` is an SQLAlchemy model definition. By its nature,
it just needs to be defined, and not necessarily *used*.

Synopsis::

pip install pytest crate[sqlalchemy]
Expand All @@ -12,11 +15,9 @@
import pytest
import sqlalchemy as sa
from crate.client.cursor import Cursor
from crate.client.sqlalchemy.types import ObjectArray
from sqlalchemy.orm import declarative_base

pytest.skip(reason="Implementation incomplete", allow_module_level=True)


fake_cursor = MagicMock(name="fake_cursor")
FakeCursor = MagicMock(name="FakeCursor", spec=Cursor)
FakeCursor.return_value = fake_cursor
Expand All @@ -35,6 +36,10 @@ def db():

@patch("crate.client.connection.Cursor", FakeCursor)
def test_table_with_object_array(db):
class DummyTable(db.Base):

Check notice

Code scanning / CodeQL

Unused local variable

Variable DummyTable is not used.
__tablename__ = "t"
pk = sa.Column(sa.String, primary_key=True)
tags = sa.Column(ObjectArray)

db.Base.metadata.create_all()
fake_cursor.execute.assert_called_with(
Expand Down