KEMBAR78
remove non-model overload for Field descriptor by asottile-sentry · Pull Request #4 · getsentry/sentry-forked-django-stubs · GitHub
Skip to content

Conversation

@asottile-sentry
Copy link

(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved

little testcase for this:

from __future__ import annotations

from django.db import models

class M1(models.Model):
    f: models.Field[int, int] = models.IntegerField()

class C:
    f: int

def f(inst: C | M1 | M2) -> int:
    return inst.f

# should also work with field subclasses
class F(models.Field[int, int]):
    pass

class M2(models.Model):
    f = F()

def g(inst: C | M2) -> int:
    return inst.f

@asottile-sentry asottile-sentry requested review from a team November 9, 2023 16:56
@asottile-sentry asottile-sentry force-pushed the sentry-4-2-6-field-descriptor branch from 7c7d3fb to 82a2c16 Compare November 9, 2023 17:02
(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved
@asottile-sentry asottile-sentry force-pushed the sentry-4-2-6-field-descriptor branch from 82a2c16 to 7062613 Compare November 9, 2023 17:11
@asottile-sentry asottile-sentry merged commit 5af709a into sentry-4.2.6 Nov 9, 2023
@asottile-sentry asottile-sentry deleted the sentry-4-2-6-field-descriptor branch November 9, 2023 17:22
asottile-sentry added a commit that referenced this pull request Dec 5, 2023
(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved
asottile-sentry added a commit that referenced this pull request Apr 30, 2024
(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved
asottile-sentry added a commit that referenced this pull request May 28, 2024
(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved
asottile-sentry added a commit to getsentry/sentry that referenced this pull request Jul 31, 2024
<!-- Describe your PR here. -->

this had three sets of breakage addressed by other PRs:

- our foreign key subclass was not functioning, django-stubs added a
default TypeVar here which started getting filled in with an unbound
TypeVar resulting in thousands of errors: fixed by
#75228
- we were able to remove our fork's [descriptor
patch](getsentry/sentry-forked-django-stubs#4)
(which removed the non-model overload of `__get__` for fields) as mypy
[fixed this issue](python/mypy#17381). in doing
so it pointed out an unsafe descriptor access through a mixin and so
that had to go: #75360
- django-stubs improved some field validation through QuerySets which
was only checked through managers before: fixed by
#75359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants