Skip to content
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
5 changes: 5 additions & 0 deletions django-stubs/contrib/gis/db/backends/oracle/features.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from typing import Any

from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures
from django.utils.functional import cached_property

class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
supports_add_srs_entry: bool
supports_geometry_field_introspection: bool
supports_geometry_field_unique_index: bool
supports_perimeter_geodetic: bool
supports_dwithin_distance_expr: bool
@cached_property
def django_test_skips(self) -> dict[str, Any]: ... # type: ignore[override]
1 change: 1 addition & 0 deletions django-stubs/db/models/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ from .lookups import Transform as Transform
from .manager import Manager as Manager
from .query import Prefetch as Prefetch
from .query import QuerySet as QuerySet
from .query import aprefetch_related_objects as aprefetch_related_objects
from .query import prefetch_related_objects as prefetch_related_objects
from .query_utils import FilteredRelation as FilteredRelation
from .query_utils import Q as Q
3 changes: 3 additions & 0 deletions django-stubs/db/models/query_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ from django.db.models.sql.compiler import SQLCompiler, _AsSqlType
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode
from django.utils import tree
from django.utils.functional import cached_property

PathInfo = namedtuple(
"PathInfo", ["from_opts", "to_opts", "target_fields", "join_field", "m2m", "direct", "filtered_relation"]
Expand Down Expand Up @@ -44,6 +45,8 @@ class Q(tree.Node):
def flatten(self) -> Iterator[Incomplete]: ...
def check(self, against: dict[str, Any], using: str = ...) -> bool: ...
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
@cached_property
def referenced_base_fields(self) -> set[str]: ...

class DeferredAttribute:
field: Field
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ plugins =
disallow_untyped_defs = false
disallow_incomplete_defs = false

[mypy-cryptography.*]
ignore_errors = true

[mypy.plugins.django-stubs]
django_settings_module = scripts.django_tests_settings
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pytest-shard==0.1.2

# Django deps:
psycopg2-binary
Django==4.2.11; python_version < '3.10'
Django==5.0.4; python_version >= '3.10'
Django==4.2.12; python_version < '3.10'
Django==5.0.5; python_version >= '3.10'
-e ./ext
-e .[redis,compatible-mypy]
-e .[redis,compatible-mypy,oracle]

# Overrides:
mypy==1.10.0
4 changes: 4 additions & 0 deletions scripts/stubtest/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ django.urls.resolvers.URLPattern.lookup_str
django.urls.resolvers.URLResolver.url_patterns
django.urls.resolvers.URLResolver.urlconf_module
django.utils.connection.BaseConnectionHandler.settings
django.db.models.Q.referenced_base_fields
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have to figure out a way to work with cached_property without this hack

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Django was planning to replace their homegrown cached_property implementation with functools.cached_property in 5.1 or 5.2.

If we have the patience to wait until then, this will resolve itself 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might take quite some time? According to this comment and ticket https://code.djangoproject.com/ticket/30949#comment:14

Or is it mentioned to be replaced someplace else?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think you're right, it will take years.

django.db.models.query_utils.Q.referenced_base_fields
django.contrib.gis.db.models.Q.referenced_base_fields
django.db.backends.oracle.features.DatabaseFeatures.django_test_skips

# Ignore missing inner `Meta` class, see PR #2000 for the related discussion
django.contrib.auth.base_user.AbstractBaseUser.Meta
Expand Down
8 changes: 0 additions & 8 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,9 @@ django.contrib.gis.db.backends.base.operations.BaseSpatialOperations.mariadb
django.contrib.gis.db.backends.mysql.base
django.contrib.gis.db.backends.mysql.features.DatabaseFeatures.unsupported_geojson_options
django.contrib.gis.db.backends.mysql.introspection
django.contrib.gis.db.backends.oracle.adapter
django.contrib.gis.db.backends.oracle.base
django.contrib.gis.db.backends.oracle.features.DatabaseFeatures.django_test_skips
django.contrib.gis.db.backends.oracle.features.DatabaseFeatures.supports_tolerance_parameter
django.contrib.gis.db.backends.oracle.features.DatabaseFeatures.unsupported_geojson_options
django.contrib.gis.db.backends.oracle.introspection
django.contrib.gis.db.backends.oracle.operations
django.contrib.gis.db.backends.postgis.adapter.PostGISAdapter.prepare
django.contrib.gis.db.backends.postgis.features.DatabaseFeatures.empty_intersection_returns_none
django.contrib.gis.db.backends.postgis.features.DatabaseFeatures.supports_geography
Expand Down Expand Up @@ -592,12 +588,8 @@ django.db.backends.mysql.features.DatabaseFeatures.supports_table_check_constrai
django.db.backends.mysql.features.DatabaseFeatures.test_collations
django.db.backends.mysql.introspection
django.db.backends.mysql.schema.DatabaseSchemaEditor.sql_alter_column_comment
django.db.backends.oracle.base
django.db.backends.oracle.features.DatabaseFeatures.introspected_field_types
django.db.backends.oracle.features.DatabaseFeatures.supports_collation_on_charfield
django.db.backends.oracle.introspection
django.db.backends.oracle.operations
django.db.backends.oracle.utils
django.db.backends.postgresql.base.DatabaseWrapper.Database
django.db.backends.postgresql.base.DatabaseWrapper.ensure_role
django.db.backends.postgresql.base.DatabaseWrapper.ops
Expand Down
9 changes: 9 additions & 0 deletions scripts/stubtest/allowlist_todo_django50.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,12 @@ django.forms.fields_for_model
django.forms.models.fields_for_model
django.forms.widgets.ClearableFileInput.checked
django.template.autoreload

# Django + Oracle (new errors after 5.0.5 update)
django.db.backends.oracle.utils.dsn
django.db.backends.oracle.utils.BulkInsertMapper.NCLOB
django.db.backends.oracle.introspection.TableInfo
django.db.backends.oracle.base.DatabaseWrapper.oracledb_version
django.db.backends.oracle.base.DatabaseWrapper.ops
django.contrib.gis.db.backends.oracle.operations.OracleOperations.from_text
django.contrib.gis.db.backends.oracle.operations.OracleOperations.convert_extent
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def find_stub_files(name: str) -> List[str]:
extras_require = {
"compatible-mypy": ["mypy~=1.10.0"],
"redis": ["redis"],
"oracle": ["oracledb"],
}

setup(
Expand Down