File: test_connection.yml

package info (click to toggle)
python-django-stubs 5.2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (25 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-   case: raw_default_connection
    main: |
      from typing_extensions import reveal_type
      from django.db import connection
      with connection.cursor() as cursor:
        reveal_type(cursor)  # N: Revealed type is "django.db.backends.utils.CursorWrapper"
        cursor.execute("SELECT %s", [123])


-   case: raw_connection_psycopg2_composable
    main: |
      from django.db import connection
      from psycopg2.sql import SQL, Identifier  # type: ignore [import-untyped]
      with connection.cursor() as cursor:
        cursor.execute(SQL("INSERT INTO {} VALUES (%s)").format(Identifier("my_table")), [123])


-   case: raw_connections
    main: |
      from typing_extensions import reveal_type
      from django.db import connections
      reveal_type(connections["test"])  # N: Revealed type is "django.db.backends.base.base.BaseDatabaseWrapper"
      for connection in connections.all():
        with connection.cursor() as cursor:
          reveal_type(cursor)  # N: Revealed type is "django.db.backends.utils.CursorWrapper"