Skip to content

Commit ce370ea

Browse files
authored
Missing stubs (#467)
* adding missing db.backends typings and updated test * added missing stubs * reformatted files * removed contrib.postgres.forms * fixed test
1 parent 2a732fd commit ce370ea

File tree

188 files changed

+4708
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+4708
-21
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pip-wheel-metadata/
1111
.pytest_cache/
1212
/.envrc
1313
/.direnv
14-
django-sources/
14+
django-sources/
15+
.venv/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django.core.exceptions import SuspiciousOperation as SuspiciousOperation
2+
3+
class DisallowedModelAdminLookup(SuspiciousOperation): ...
4+
class DisallowedModelAdminToField(SuspiciousOperation): ...

django-stubs/contrib/admin/migrations/__init__.pyi

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig as AppConfig
2+
from typing import Any
3+
4+
class AdminDocsConfig(AppConfig):
5+
name: str = ...
6+
verbose_name: Any = ...

django-stubs/contrib/auth/migrations/__init__.pyi

Whitespace-only changes.

django-stubs/contrib/contenttypes/migrations/__init__.pyi

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.contrib import admin as admin
2+
from typing import Any
3+
4+
class FlatPageAdmin(admin.ModelAdmin):
5+
form: Any = ...
6+
fieldsets: Any = ...
7+
list_display: Any = ...
8+
list_filter: Any = ...
9+
search_fields: Any = ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig as AppConfig
2+
from typing import Any
3+
4+
class FlatPagesConfig(AppConfig):
5+
name: str = ...
6+
verbose_name: Any = ...

django-stubs/contrib/flatpages/migrations/__init__.pyi

Whitespace-only changes.

django-stubs/contrib/gis/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config: str
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.contrib.admin import (
2+
AdminSite as AdminSite,
3+
HORIZONTAL as HORIZONTAL,
4+
ModelAdmin as ModelAdmin,
5+
StackedInline as StackedInline,
6+
TabularInline as TabularInline,
7+
VERTICAL as VERTICAL,
8+
autodiscover as autodiscover,
9+
register as register,
10+
site as site,
11+
)
12+
from django.contrib.gis.admin.options import GeoModelAdmin as GeoModelAdmin, OSMGeoAdmin as OSMGeoAdmin
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from django.contrib.admin import ModelAdmin as ModelAdmin
2+
from typing import Any
3+
4+
spherical_mercator_srid: int
5+
6+
class GeoModelAdmin(ModelAdmin):
7+
default_lon: int = ...
8+
default_lat: int = ...
9+
default_zoom: int = ...
10+
display_wkt: bool = ...
11+
display_srid: bool = ...
12+
extra_js: Any = ...
13+
num_zoom: int = ...
14+
max_zoom: bool = ...
15+
min_zoom: bool = ...
16+
units: bool = ...
17+
max_resolution: bool = ...
18+
max_extent: bool = ...
19+
modifiable: bool = ...
20+
mouse_position: bool = ...
21+
scale_text: bool = ...
22+
layerswitcher: bool = ...
23+
scrollable: bool = ...
24+
map_width: int = ...
25+
map_height: int = ...
26+
map_srid: int = ...
27+
map_template: str = ...
28+
openlayers_url: str = ...
29+
point_zoom: Any = ...
30+
wms_url: str = ...
31+
wms_layer: str = ...
32+
wms_name: str = ...
33+
wms_options: Any = ...
34+
debug: bool = ...
35+
widget: Any = ...
36+
@property
37+
def media(self): ...
38+
def formfield_for_dbfield(self, db_field: Any, request: Any, **kwargs: Any): ...
39+
def get_map_widget(self, db_field: Any): ...
40+
41+
class OSMGeoAdmin(GeoModelAdmin):
42+
map_template: str = ...
43+
num_zoom: int = ...
44+
map_srid: Any = ...
45+
point_zoom: Any = ...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.forms.widgets import Textarea as Textarea
2+
from typing import Any
3+
4+
geo_context: Any
5+
logger: Any
6+
7+
class OpenLayersWidget(Textarea):
8+
def get_context(self, name: Any, value: Any, attrs: Any): ...
9+
def map_options(self): ...

django-stubs/contrib/gis/apps.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig as AppConfig
2+
from typing import Any
3+
4+
class GISConfig(AppConfig):
5+
name: str = ...
6+
verbose_name: Any = ...
7+
def ready(self) -> None: ...

django-stubs/contrib/gis/db/backends/__init__.pyi

Whitespace-only changes.

django-stubs/contrib/gis/db/backends/base/__init__.pyi

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Any
2+
3+
class WKTAdapter:
4+
wkt: Any = ...
5+
srid: Any = ...
6+
def __init__(self, geom: Any) -> None: ...
7+
def __eq__(self, other: Any) -> Any: ...
8+
def __hash__(self) -> Any: ...
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from typing import Any
2+
3+
class BaseSpatialFeatures:
4+
gis_enabled: bool = ...
5+
has_spatialrefsys_table: bool = ...
6+
supports_add_srs_entry: bool = ...
7+
supports_geometry_field_introspection: bool = ...
8+
supports_3d_storage: bool = ...
9+
supports_3d_functions: bool = ...
10+
supports_transform: bool = ...
11+
supports_null_geometries: bool = ...
12+
supports_empty_geometries: bool = ...
13+
supports_distance_geodetic: bool = ...
14+
supports_length_geodetic: bool = ...
15+
supports_perimeter_geodetic: bool = ...
16+
supports_area_geodetic: bool = ...
17+
supports_num_points_poly: bool = ...
18+
supports_left_right_lookups: bool = ...
19+
supports_dwithin_distance_expr: bool = ...
20+
supports_raster: bool = ...
21+
supports_geometry_field_unique_index: bool = ...
22+
@property
23+
def supports_bbcontains_lookup(self): ...
24+
@property
25+
def supports_contained_lookup(self): ...
26+
@property
27+
def supports_crosses_lookup(self): ...
28+
@property
29+
def supports_distances_lookups(self): ...
30+
@property
31+
def supports_dwithin_lookup(self): ...
32+
@property
33+
def supports_relate_lookup(self): ...
34+
@property
35+
def supports_isvalid_lookup(self): ...
36+
@property
37+
def supports_collect_aggr(self): ...
38+
@property
39+
def supports_extent_aggr(self): ...
40+
@property
41+
def supports_make_line_aggr(self): ...
42+
@property
43+
def supports_union_aggr(self): ...
44+
def __getattr__(self, name: Any): ...
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any
2+
3+
class SpatialRefSysMixin:
4+
@property
5+
def srs(self): ...
6+
@property
7+
def ellipsoid(self): ...
8+
@property
9+
def name(self): ...
10+
@property
11+
def spheroid(self): ...
12+
@property
13+
def datum(self): ...
14+
@property
15+
def projected(self): ...
16+
@property
17+
def local(self): ...
18+
@property
19+
def geographic(self): ...
20+
@property
21+
def linear_name(self): ...
22+
@property
23+
def linear_units(self): ...
24+
@property
25+
def angular_name(self): ...
26+
@property
27+
def angular_units(self): ...
28+
@property
29+
def units(self): ...
30+
@classmethod
31+
def get_units(cls, wkt: Any): ...
32+
@classmethod
33+
def get_spheroid(cls, wkt: Any, string: bool = ...): ...
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any
2+
3+
class BaseSpatialOperations:
4+
postgis: bool = ...
5+
spatialite: bool = ...
6+
mysql: bool = ...
7+
oracle: bool = ...
8+
spatial_version: Any = ...
9+
select: str = ...
10+
def select_extent(self): ...
11+
geography: bool = ...
12+
geometry: bool = ...
13+
disallowed_aggregates: Any = ...
14+
geom_func_prefix: str = ...
15+
function_names: Any = ...
16+
unsupported_functions: Any = ...
17+
from_text: bool = ...
18+
def convert_extent(self, box: Any, srid: Any) -> None: ...
19+
def convert_extent3d(self, box: Any, srid: Any) -> None: ...
20+
def geo_quote_name(self, name: Any): ...
21+
def geo_db_type(self, f: Any) -> None: ...
22+
def get_distance(self, f: Any, value: Any, lookup_type: Any) -> None: ...
23+
def get_geom_placeholder(self, f: Any, value: Any, compiler: Any): ...
24+
def check_expression_support(self, expression: Any) -> None: ...
25+
def spatial_aggregate_name(self, agg_name: Any) -> None: ...
26+
def spatial_function_name(self, func_name: Any): ...
27+
def geometry_columns(self) -> None: ...
28+
def spatial_ref_sys(self) -> None: ...
29+
distance_expr_for_lookup: Any = ...
30+
def get_db_converters(self, expression: Any): ...
31+
def get_geometry_converter(self, expression: Any) -> None: ...
32+
def get_area_att_for_field(self, field: Any): ...
33+
def get_distance_att_for_field(self, field: Any): ...

django-stubs/contrib/gis/db/backends/mysql/__init__.pyi

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper
2+
from typing import Any
3+
4+
class DatabaseWrapper(MySQLDatabaseWrapper):
5+
SchemaEditorClass: Any = ...
6+
features_class: Any = ...
7+
introspection_class: Any = ...
8+
ops_class: Any = ...
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
2+
from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures
3+
4+
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
5+
has_spatialrefsys_table: bool = ...
6+
supports_add_srs_entry: bool = ...
7+
supports_distance_geodetic: bool = ...
8+
supports_length_geodetic: bool = ...
9+
supports_area_geodetic: bool = ...
10+
supports_transform: bool = ...
11+
supports_null_geometries: bool = ...
12+
supports_num_points_poly: bool = ...
13+
def supports_empty_geometry_collection(self): ...
14+
def supports_geometry_field_unique_index(self): ...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.db.backends.mysql.introspection import DatabaseIntrospection as DatabaseIntrospection
2+
from typing import Any
3+
4+
class MySQLIntrospection(DatabaseIntrospection):
5+
data_types_reverse: Any = ...
6+
def get_geometry_type(self, table_name: Any, description: Any): ...
7+
def supports_spatial_index(self, cursor: Any, table_name: Any): ...
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations
2+
from django.db.backends.mysql.operations import DatabaseOperations as DatabaseOperations
3+
from typing import Any
4+
5+
class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
6+
mysql: bool = ...
7+
name: str = ...
8+
geom_func_prefix: str = ...
9+
Adapter: Any = ...
10+
def select(self): ...
11+
def from_text(self): ...
12+
def gis_operators(self): ...
13+
disallowed_aggregates: Any = ...
14+
def unsupported_functions(self): ...
15+
def geo_db_type(self, f: Any): ...
16+
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
17+
def get_geometry_converter(self, expression: Any): ...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.db.backends.mysql.schema import DatabaseSchemaEditor as DatabaseSchemaEditor
2+
from typing import Any
3+
4+
logger: Any
5+
6+
class MySQLGISSchemaEditor(DatabaseSchemaEditor):
7+
sql_add_spatial_index: str = ...
8+
sql_drop_spatial_index: str = ...
9+
geometry_sql: Any = ...
10+
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
11+
def skip_default(self, field: Any): ...
12+
def column_sql(self, model: Any, field: Any, include_default: bool = ...): ...
13+
def create_model(self, model: Any) -> None: ...
14+
def add_field(self, model: Any, field: Any) -> None: ...
15+
def remove_field(self, model: Any, field: Any) -> None: ...
16+
def create_spatial_indexes(self) -> None: ...

django-stubs/contrib/gis/db/backends/oracle/__init__.pyi

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
2+
from typing import Any
3+
4+
class OracleSpatialAdapter(WKTAdapter):
5+
input_size: Any = ...
6+
wkt: Any = ...
7+
srid: Any = ...
8+
def __init__(self, geom: Any) -> None: ...
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper
2+
from typing import Any
3+
4+
class DatabaseWrapper(OracleDatabaseWrapper):
5+
SchemaEditorClass: Any = ...
6+
features_class: Any = ...
7+
introspection_class: Any = ...
8+
ops_class: Any = ...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
2+
from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures
3+
4+
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
5+
supports_add_srs_entry: bool = ...
6+
supports_geometry_field_introspection: bool = ...
7+
supports_geometry_field_unique_index: bool = ...
8+
supports_perimeter_geodetic: bool = ...
9+
supports_dwithin_distance_expr: bool = ...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.db.backends.oracle.introspection import DatabaseIntrospection as DatabaseIntrospection
2+
from typing import Any
3+
4+
class OracleIntrospection(DatabaseIntrospection):
5+
def data_types_reverse(self): ...
6+
def get_geometry_type(self, table_name: Any, description: Any): ...
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from django.contrib.gis.db import models as models
2+
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as SpatialRefSysMixin
3+
from typing import Any
4+
5+
class OracleGeometryColumns(models.Model):
6+
table_name: Any = ...
7+
column_name: Any = ...
8+
srid: Any = ...
9+
class Meta:
10+
app_label: str = ...
11+
db_table: str = ...
12+
managed: bool = ...
13+
@classmethod
14+
def table_name_col(cls): ...
15+
@classmethod
16+
def geom_col_name(cls): ...
17+
18+
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
19+
cs_name: Any = ...
20+
srid: Any = ...
21+
auth_srid: Any = ...
22+
auth_name: Any = ...
23+
wktext: Any = ...
24+
cs_bounds: Any = ...
25+
class Meta:
26+
app_label: str = ...
27+
db_table: str = ...
28+
managed: bool = ...
29+
@property
30+
def wkt(self): ...

0 commit comments

Comments
 (0)