Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove non-model overload for Field descriptor #4

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

asottile-sentry
Copy link
Member

(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

(not upstreamed)

hopefully eventually can remove when python/mypy#5570 is solved
@asottile-sentry asottile-sentry merged commit 5af709a into sentry-4.2.6 Nov 9, 2023
16 checks passed
@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 that referenced this pull request Jul 29, 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