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 jinja2 import select_autoescape | ||
|
|
||
| import django_stubs_ext # noqa: I100, I102, I202 | ||
| django_stubs_ext.monkeypatch() |
There was a problem hiding this comment.
is it necessary to keep monkeypatch() out of TYPE_CHECKING?
There was a problem hiding this comment.
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 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.
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.
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.
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.