Skip to content

Commit 77b2152

Browse files
Fix missing at runtime errors (batch 3) (#2639)
* Handle os specific stubs * Fix some const names * Remove `as_subquery_condition` * Remove `deferred_to_columns` * Fix `ConnectionHandler` types * Remove `_get_flatchoices` * Remove `check_supported` * Move outbox allowlist entry
1 parent 3be2d2a commit 77b2152

File tree

11 files changed

+15
-40
lines changed

11 files changed

+15
-40
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
GDAL_PIXEL_TYPES: dict[int, str]
22
GDAL_INTEGER_TYPES: list[int]
3-
GDAL_TO_CTYPES: type
3+
GDAL_TO_CTYPES: list[type | None]
44
GDAL_RESAMPLE_ALGORITHMS: dict[str, int]
55
GDAL_COLOR_TYPES: dict[int, str]
6-
VSI_FILESYSTEM_BASE_PATH: str
6+
VSI_FILESYSTEM_PREFIX: str
7+
VSI_MEM_FILESYSTEM_BASE_PATH: str
78
VSI_TAKE_BUFFER_OWNERSHIP: bool
89
VSI_DELETE_BUFFER_ON_READ: bool

django-stubs/contrib/postgres/constraints.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections.abc import Iterable, Sequence
22

3-
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
43
from django.db.models import Deferrable
54
from django.db.models.base import Model
65
from django.db.models.constraints import BaseConstraint
@@ -28,7 +27,6 @@ class ExclusionConstraint(BaseConstraint):
2827
violation_error_code: str | None = None,
2928
violation_error_message: _StrOrPromise | None = None,
3029
) -> None: ...
31-
def check_supported(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
3230
def validate(
3331
self, model: type[Model], instance: Model, exclude: Iterable[str] | None = None, using: str = "default"
3432
) -> None: ...

django-stubs/core/files/locks.pyi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import sys
12
from ctypes import Structure, Union
23
from typing import Any
34

45
LOCK_SH: int
56
LOCK_NB: int
67
LOCK_EX: int
7-
ULONG_PTR: Any
8-
PVOID: Any
98

10-
class _OFFSET(Structure): ...
11-
class _OFFSET_UNION(Union): ...
12-
class OVERLAPPED(Structure): ...
9+
if sys.platform == "win32":
10+
ULONG_PTR: Any
11+
PVOID: Any
12+
class _OFFSET(Structure): ...
13+
class _OFFSET_UNION(Union): ...
14+
class OVERLAPPED(Structure): ...
1315

1416
def lock(f: Any, flags: int) -> bool: ...
1517
def unlock(f: Any) -> bool: ...

django-stubs/db/backends/mysql/compiler.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
from typing import Any
2-
31
from django.db.models.sql import compiler
42
from django.db.models.sql.compiler import _AsSqlType
53

6-
class SQLCompiler(compiler.SQLCompiler):
7-
def as_subquery_condition(self, alias: Any, columns: Any, compiler: Any) -> _AsSqlType: ...
8-
4+
class SQLCompiler(compiler.SQLCompiler): ...
95
class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler): ...
106

117
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):

django-stubs/db/migrations/graph.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ from typing import Any
44
from django.db.migrations.migration import Migration
55
from django.db.migrations.state import ProjectState
66

7-
RECURSION_DEPTH_WARNING: str
8-
97
class Node:
108
key: tuple[str, str]
119
children: set[Any]

django-stubs/db/models/fields/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
224224
limit_choices_to: _LimitChoicesTo | None = None,
225225
ordering: Sequence[str] = (),
226226
) -> BlankChoiceIterator | _ChoicesList: ...
227-
def _get_flatchoices(self) -> list[_Choice]: ...
228227
@property
229228
def flatchoices(self) -> list[_Choice]: ...
230229
def has_default(self) -> bool: ...

django-stubs/db/models/sql/compiler.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class SQLCompiler:
8787
restricted: bool | None = None,
8888
) -> list[dict[str, Any]]: ...
8989
def get_select_for_update_of_arguments(self) -> list[Any]: ...
90-
def deferred_to_columns(self) -> dict[type[Model], set[str]]: ...
9190
def get_converters(self, expressions: list[Expression]) -> dict[int, tuple[list[Callable], Expression]]: ...
9291
def apply_converters(
9392
self, rows: Iterable[Iterable[Any]], converters: dict[int, tuple[list[Callable], Expression]]
@@ -119,7 +118,6 @@ class SQLCompiler:
119118
def execute_sql(
120119
self, result_type: Literal["multi"] = "multi", chunked_fetch: bool = False, chunk_size: int = 100
121120
) -> Iterable[list[Sequence[Any]]] | None: ...
122-
def as_subquery_condition(self, alias: str, columns: list[str], compiler: SQLCompiler) -> _AsSqlType: ...
123121
def explain_query(self) -> Iterator[str]: ...
124122

125123
class SQLInsertCompiler(SQLCompiler):

django-stubs/db/utils.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ class DatabaseErrorWrapper:
3434
def load_backend(backend_name: str) -> Any: ...
3535

3636
class ConnectionHandler(BaseConnectionHandler[BaseDatabaseWrapper]):
37+
def configure_settings(self, databases: dict[str, Any] | None) -> dict[str, Any]: ...
3738
@property
3839
def databases(self) -> dict[str, dict[str, Any]]: ...
39-
def ensure_defaults(self, alias: str) -> None: ...
40-
def prepare_test_settings(self, alias: str) -> None: ...
4140
def create_connection(self, alias: str) -> BaseDatabaseWrapper: ...
4241
def close_all(self) -> None: ...
4342

scripts/stubtest/allowlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,6 @@ django.forms.models.BaseModelForm.save_m2m
547547
django.forms.models.BaseModelFormSet.save_m2m
548548
django.contrib.gis.forms.BaseModelForm.save_m2m
549549
django.contrib.gis.forms.BaseModelFormSet.save_m2m
550+
551+
# Dynamically generated in https://github.com/django/django/blame/0ee06c04e0256094270db3ffe8b5dafa6a8457a3/django/core/mail/backends/locmem.py#L24
552+
django.core.mail.outbox

scripts/stubtest/allowlist_todo.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ django.contrib.gis.gdal.envelope.OGREnvelope.MinY
374374
django.contrib.gis.gdal.geometries.LineString.coords
375375
django.contrib.gis.gdal.geometries.OGRGeometry.geojson
376376
django.contrib.gis.gdal.geometries.Polygon.exterior_ring
377-
django.contrib.gis.gdal.raster.const.GDAL_TO_CTYPES
378-
django.contrib.gis.gdal.raster.const.VSI_FILESYSTEM_BASE_PATH
379-
django.contrib.gis.gdal.raster.const.VSI_FILESYSTEM_PREFIX
380-
django.contrib.gis.gdal.raster.const.VSI_MEM_FILESYSTEM_BASE_PATH
381377
django.contrib.gis.gdal.srs.SpatialReference.pretty_wkt
382378
django.contrib.gis.gdal.srs.SpatialReference.xml
383379
django.contrib.gis.geos.Point.tuple
@@ -434,9 +430,6 @@ django.contrib.staticfiles.finders.BaseStorageFinder.storage
434430
django.contrib.staticfiles.finders.DefaultStorageFinder.storage
435431
django.contrib.staticfiles.storage.staticfiles_storage
436432
django.core.cache.cache
437-
django.core.files.locks.OVERLAPPED
438-
django.core.files.locks.PVOID
439-
django.core.files.locks.ULONG_PTR
440433
django.core.files.uploadedfile.UploadedFile.size
441434
django.core.files.utils.FileProxyMixin.encoding
442435
django.core.files.utils.FileProxyMixin.fileno
@@ -461,7 +454,6 @@ django.core.mail.backends.locmem.EmailBackend.send_messages
461454
django.core.mail.backends.smtp.EmailBackend.__init__
462455
django.core.mail.backends.smtp.EmailBackend.connection_class
463456
django.core.mail.backends.smtp.EmailBackend.ssl_context
464-
django.core.mail.outbox
465457
django.core.management.commands.makemessages.TranslatableFile.__ge__
466458
django.core.management.commands.makemessages.TranslatableFile.__gt__
467459
django.core.management.commands.makemessages.TranslatableFile.__le__
@@ -528,7 +520,6 @@ django.db.migrations.Migration.suggest_name
528520
django.db.migrations.graph.Node.__ge__
529521
django.db.migrations.graph.Node.__gt__
530522
django.db.migrations.graph.Node.__le__
531-
django.db.migrations.graph.RECURSION_DEPTH_WARNING
532523
django.db.migrations.loader.MigrationLoader.collect_sql
533524
django.db.migrations.migration.Migration.suggest_name
534525
django.db.migrations.operations.utils
@@ -955,7 +946,6 @@ django.db.models.query_utils.select_related_descend
955946
django.db.models.sql.AggregateQuery.__init__
956947
django.db.models.sql.InsertQuery.__init__
957948
django.db.models.sql.compiler.SQLCompiler.__init__
958-
django.db.models.sql.compiler.SQLCompiler.deferred_to_columns
959949
django.db.models.sql.compiler.SQLCompiler.get_default_columns
960950
django.db.models.sql.compiler.SQLCompiler.get_qualify_sql
961951
django.db.models.sql.compiler.SQLCompiler.get_related_selections
@@ -975,9 +965,6 @@ django.db.models.sql.where.WhereNode.replace_expressions
975965
django.db.models.sql.where.WhereNode.set_source_expressions
976966
django.db.models.sql.where.WhereNode.split_having
977967
django.db.models.sql.where.WhereNode.split_having_qualify
978-
django.db.utils.ConnectionHandler.configure_settings
979-
django.db.utils.ConnectionHandler.ensure_defaults
980-
django.db.utils.ConnectionHandler.prepare_test_settings
981968
django.db.utils.DatabaseErrorWrapper.__call__
982969
django.forms.ALL_FIELDS
983970
django.forms.BaseForm.__init__

0 commit comments

Comments
 (0)