Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Commit cb06491

Browse files
committed
Switch to mypy
This is a work-in-progress attempt at switching over to mypy as part of #85. There's still some work to be done (e.g. mypy ignore comments need to be added where appropriate) and I'm currently working with some local changes pyre's stubs, but I wanted to track the work being done.
1 parent 1712ac9 commit cb06491

56 files changed

Lines changed: 42 additions & 134 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ indent_style = space
2929
atomic = true
3030
force_sort_within_sections = true
3131
include_trailing_comma = true
32-
known_third_party = decouple,django,factory,pytest,sesame
3332
multi_line_output = 3
3433

3534
[.pyre_configuration]

.flake8

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,5 @@ ignore = E203, E231, E266, E501, W503
44
max-line-length = 80
55
max-complexity = 18
66
per-file-ignores =
7-
src/awards/settings/dev.py: F405
8-
# TODO: Remove these once
9-
# https://github.com/facebook/pyre-check/pull/256,
10-
# https://github.com/facebook/pyre-check/pull/260,
11-
# https://github.com/facebook/pyre-check/pull/261, and
12-
# https://github.com/facebook/pyre-check/pull/262 can be used.
13-
src/applications/forms.py: B950
14-
src/applications/migrations/0003_auto_20200507_0125.py: B950
15-
src/applications/models.py: B950
16-
src/applications/test_views.py: B950
17-
src/awards/urls.py: B950
18-
src/homepage/test_views.py: B950
19-
src/users/migrations/0001_initial.py: B950
20-
src/users/forms.py: B950
21-
src/users/models.py: B950
22-
src/users/views.py: B950
7+
awards/settings/dev.py: F405
238
select = B,C,E,F,W,T4,B9

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ repos:
3030
hooks:
3131
- id: autoflake
3232
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
33-
- repo: https://github.com/asottile/seed-isort-config
34-
rev: v2.2.0
35-
hooks:
36-
- id: seed-isort-config
37-
args: ['--application-directories=src']
3833
- repo: https://github.com/timothycrosley/isort
3934
rev: 5.6.4
4035
hooks:

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ environment. It can be output without running the unit tests with::
7070
Type checks
7171
-----------
7272

73-
The type checks are done using pyre_ and can be run with::
73+
The type checks are done using Mypy_ and can be run with::
7474

7575
$ tox -e types
7676

@@ -128,9 +128,9 @@ will be removed from the repository.
128128
.. _citext: https://www.postgresql.org/docs/current/citext.html
129129
.. _Hacktoberfest: https://hacktoberfest.digitalocean.com
130130
.. _ipython: https://ipython.readthedocs.io
131+
.. _Mypy: https://mypy.readthedocs.io
131132
.. _PostgreSQL: https://www.postgresql.org
132133
.. _psql: https://www.postgresql.org/docs/current/app-psql.html
133-
.. _pyre: https://pyre-check.org
134134
.. _tox: https://tox.readthedocs.io
135135
.. _watchman: https://facebook.github.io/watchman/
136136

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class FinancialAidApplicationForm(ApplicationForm):
1717
type = Application.Type.FINANCIAL_AID
1818

1919
travel_requested = forms.BooleanField(
20-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
2120
label=_("Do you need assistance with travel?"),
2221
required=False,
2322
)
@@ -32,13 +31,9 @@ class Meta:
3231
"lodging_requested",
3332
)
3433
labels = {
35-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
3634
"background": _("Tell us a little bit more about yourself"),
37-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
3835
"lodging_requested": _("Do you need assistance with lodging?"),
39-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
4036
"reason_to_attend": _("Why are you interested in attending PyGotham?"),
41-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
4237
"travel_amount": _("What is the estimated cost (USD)?"),
4338
}
4439
widgets = {
@@ -51,39 +46,28 @@ def clean(self) -> Dict[str, Any]:
5146
travel_amount = cleaned_data.get("travel_amount") or 0
5247
if travel_amount < 0:
5348
raise forms.ValidationError(
54-
{
55-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
56-
"travel_amount": _(
57-
"Your estimated travel costs cannot be negative."
58-
)
59-
}
49+
{"travel_amount": _("Your estimated travel costs cannot be negative.")}
6050
)
6151

6252
travel_requested = cleaned_data.get("travel_requested")
6353
if travel_requested:
6454
if not travel_amount:
6555
raise forms.ValidationError(
6656
{
67-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
6857
"travel_amount": _(
6958
"Your estimated travel costs must be greater than $0.00."
7059
)
7160
}
7261
)
7362
elif travel_amount:
74-
raise forms.ValidationError(
75-
{
76-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
77-
"travel_requested": _(
78-
"You must request travel assistance before providing an estimated cost."
79-
)
80-
}
63+
msg = _(
64+
"You must request travel assistance before providing an estimated cost."
8165
)
66+
raise forms.ValidationError({"travel_requested": msg})
8267

8368
return cleaned_data
8469

8570
def clean_lodging_requested(self) -> bool:
86-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/261.
8771
return bool(self.cleaned_data.get("lodging_requested"))
8872

8973

@@ -94,9 +78,7 @@ class Meta:
9478
model = Application
9579
fields = ("background", "reason_to_attend")
9680
labels = {
97-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
9881
"background": _("Tell us a little bit about yourself"),
99-
# pyre-ignore[16]: This is fixed by https://github.com/facebook/pyre-check/pull/262.
10082
"reason_to_attend": _("Why are you interested in attending PyGotham?"),
10183
}
10284

File renamed without changes.

0 commit comments

Comments
 (0)