Skip to content

Commit

Permalink
don't remove objects / DoesNotExist / etc. from model classes
Browse files Browse the repository at this point in the history
django-stubs fails to restore these in too many cases.  see upstream issue typeddjango#1744

(not upstreamed)
  • Loading branch information
asottile-sentry committed Oct 31, 2023
1 parent b431663 commit a7c65c1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,6 @@ jobs:
- name: Run mypy on stubs
run: mypy --cache-dir=/dev/null --no-incremental django-stubs

test:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
shard: [0, 1, 2, 3]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup system dependencies
run: |
sudo apt-get update
sudo apt-get install binutils libproj-dev gdal-bin
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip setuptools wheel
SETUPTOOLS_ENABLE_FEATURES=legacy-editable pip install -r ./requirements.txt
# Must match `shard` definition in the test matrix:
- name: Run tests
run: PYTHONPATH='.' pytest --num-shards=4 --shard-id=${{ matrix.shard }} tests

stubtest:
timeout-minutes: 10
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions django-stubs/contrib/sessions/base_session.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Literal, TypeVar
from typing import Any, ClassVar, Literal, TypeVar

from django.contrib.sessions.backends.base import SessionBase
from django.db import models
Expand All @@ -14,7 +14,7 @@ class AbstractBaseSession(models.Model):
expire_date: datetime
session_data: str
session_key: str
objects: Any
objects: ClassVar[Any]

class Meta:
abstract: Literal[True]
Expand Down
2 changes: 1 addition & 1 deletion mypy_django_plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def get_method_hook(self, fullname: str) -> Optional[Callable[[MethodContext], M

def get_customize_class_mro_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]:
if fullname == fullnames.MODEL_CLASS_FULLNAME:
return MetaclassAdjustments.adjust_model_class
return None

sym = self.lookup_fully_qualified(fullname)
if (
Expand Down

0 comments on commit a7c65c1

Please sign in to comment.