Skip to content

[sqlite3] Use TypeAlias for isolation_level #14460

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

Merged
merged 1 commit into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions stdlib/_sqlite3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ from sqlite3 import (
ProgrammingError as ProgrammingError,
Row as Row,
Warning as Warning,
_IsolationLevel,
)
from typing import Any, Final, Literal, TypeVar, overload
from typing import Any, Final, TypeVar, overload
from typing_extensions import TypeAlias

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -225,7 +226,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
Expand All @@ -237,7 +238,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
Expand All @@ -250,7 +251,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
Expand All @@ -265,7 +266,7 @@ else:
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
Expand All @@ -275,7 +276,7 @@ else:
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
Expand All @@ -286,7 +287,7 @@ else:
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
Expand Down
28 changes: 15 additions & 13 deletions stdlib/sqlite3/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
_AdaptedInputData: TypeAlias = _SqliteData | Any
# The Mapping must really be a dict, but making it invariant is too annoying.
_Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData]
# Controls the legacy transaction handling mode of sqlite3.
_IsolationLevel: TypeAlias = Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None

class _AnyParamWindowAggregateClass(Protocol):
def step(self, *args: Any) -> object: ...
Expand Down Expand Up @@ -285,7 +287,7 @@ class Connection:
def Warning(self) -> type[Warning]: ...
@property
def in_transaction(self) -> bool: ...
isolation_level: str | None # one of '', 'DEFERRED', 'IMMEDIATE' or 'EXCLUSIVE'
isolation_level: _IsolationLevel
@property
def total_changes(self) -> int: ...
if sys.version_info >= (3, 12):
Expand All @@ -299,26 +301,26 @@ class Connection:
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
cached_statements: int = 128,
uri: bool = False,
autocommit: bool = ...,
) -> None: ...
else:
def __init__(
self,
database: StrOrBytesPath,
timeout: float = ...,
detect_types: int = ...,
isolation_level: str | None = ...,
check_same_thread: bool = ...,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
factory: type[Connection] | None = ...,
cached_statements: int = ...,
uri: bool = ...,
cached_statements: int = 128,
uri: bool = False,
) -> None: ...

def close(self) -> None: ...
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy