-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
Improve system check registry hints #1249
Conversation
a4a1974
to
a6334c5
Compare
@sobolevn Any ideas why only "pre-commit.ci" checks are running, but not the remaining workflows? |
No :( |
After making a new push, the workflows are now running. I guess it was a temporary GitHub glitch. |
a86eef1
to
e31c9c7
Compare
This should be ready for review. @adamchainz do you have time to look at this again? |
Ping, this has been waiting for 3 weeks. @adamchainz @sobolevn? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes - writing and pushing a fix.
_CheckCallable: TypeAlias = Callable[..., Sequence[CheckMessage]] | ||
class _CheckCallable(Protocol): | ||
def __call__( | ||
self, *, app_configs: Apps, databases: Sequence[str] | None, **kwargs: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app_configs
has the wrong type - it's a list of AppConfig
, or None
.
See https://docs.djangoproject.com/en/4.1/topics/checks/#writing-your-own-checks
The check function must accept an app_configs argument; this argument is the list of applications that should be inspected. If None, the check must be run on all installed apps in the project.
And an example check function in one of my packages: https://github.com/adamchainz/django-linear-migrations/blob/main/src/django_linear_migrations/apps.py#L129
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh that was sloppy. Thanks for the fixes!
tests/typecheck/core/test_checks.yml
Outdated
@register("foo", deploy=True) | ||
def check_foo(app_configs: Apps, databases: Optional[Sequence[str]], **kwargs: Any) -> list[Warning]: | ||
if databases and 'databass' in databases: | ||
return [Warning("Naughty list")] | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most checks don't take a databases
argument, so I'd like a test that checks that situation too
Tests failing until #1313... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready to go, but I'm not going to merge as I was the last to touch it.
Thanks everyone! |
Lovely stuff, thanks everyone! |
The
@register
decorator fromdjango.core.checks
was previously untyped.Fixes #1098.