-
Notifications
You must be signed in to change notification settings - Fork 367
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
Add mypy annotations #2283
base: master
Are you sure you want to change the base?
Add mypy annotations #2283
Conversation
2a3e54f
to
0e2ef59
Compare
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #2283 +/- ##
==========================================
+ Coverage 46.84% 47.96% +1.12%
==========================================
Files 249 249
Lines 13158 13453 +295
==========================================
+ Hits 6164 6453 +289
- Misses 6994 7000 +6
☔ View full report in Codecov by Sentry. |
0e2ef59
to
c6457ad
Compare
c6457ad
to
3ff1451
Compare
3ff1451
to
17701c2
Compare
|
||
from django.utils.translation import gettext_lazy as _ | ||
from django_jinja.builtins import DEFAULT_EXTENSIONS | ||
from jinja2 import select_autoescape | ||
|
||
import django_stubs_ext # noqa: I100, I102, I202 | ||
django_stubs_ext.monkeypatch() |
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.
is it necessary to keep monkeypatch()
out of TYPE_CHECKING
?
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.
Yeah, we need it when running in production as well. Otherwise, we still get the same TypeError
(ref: https://github.com/typeddjango/django-stubs#i-cannot-use-queryset-or-manager-with-type-annotations)
17701c2
to
ba67723
Compare
|
||
# Set to 1 to use HTTPS if request was made to https:// | ||
# Set to 2 to always use HTTPS for links | ||
# Set to 0 to always use HTTP for links | ||
DMOJ_SSL = 0 | ||
DMOJ_SSL: int = 0 |
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.
Should we use Literal[0,1,2]
instead of `int?
DMOJ_TOTP_TOLERANCE_HALF_MINUTES = 1 | ||
DMOJ_SCRATCH_CODES_COUNT = 5 | ||
DMOJ_USER_MAX_ORGANIZATION_COUNT = 3 | ||
DMOJ_SUBMISSION_SOURCE_VISIBILITY: Union[Literal['all'], Literal['all-solved'], Literal['only-own']] = 'all-solved' |
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.
Does Literal['all', 'all-solved', 'only-own']
not work?
def split_path_first(path, repath=re.compile('[%s]' % re.escape(os.sep + os.altsep))): | ||
repath = re.compile('[%s]' % re.escape(os.sep + os.altsep)) | ||
|
||
def split_path_first(path): |
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.
This change seems semantically different to me; are you sure we don't (and won't need to) pass repath
as a argument to this function?
Supercedes #1495. Refs #1493.