Skip to content

Commit b432bd7

Browse files
authored
Merge pull request #96 from cmu-delphi/OKRS24-138-Fix-mypy-issues
Okrs24 138 fix mypy issues
2 parents 08b094c + 7bddeb5 commit b432bd7

File tree

13 files changed

+259
-234
lines changed

13 files changed

+259
-234
lines changed

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ celery = {version = "*", extras = ["redis"]}
4040
flower = "*"
4141
django-htmx = "*"
4242
gunicorn = "*"
43+
types-requests = "*"
4344

4445
[dev-packages]
4546
flake8 = "*"

Pipfile.lock

+173-157
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup.cfg

+9
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ plugins =
3030

3131
[mypy.plugins.django-stubs]
3232
django_settings_module = signal_documentation.settings
33+
34+
[mypy-*.migrations.*]
35+
ignore_errors = True
36+
37+
[mypy-signal_documentation.settings.*]
38+
ignore_errors = True
39+
40+
[mypy-*.tests.*]
41+
ignore_errors = True

src/base/context_processors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def filters_descriptions(request) -> dict[str, list[dict[str, Any]]]:
1010
"""
1111
descripted_filters = DescriptedFilter.objects.all()
1212

13-
results: dict[str, dict[dict[str, dict[str, str]]]] = {
13+
results: dict = {
1414
'filters_descriptions': {
1515
split_class_name(str(df.filter_name))[-1]: df.descriptions
1616
} for df in descripted_filters

src/base/models.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class DescriptedFilterField(models.Model):
1515
"""
1616
A model representing a filter field that is descripted.
1717
"""
18-
filter = models.ForeignKey(
18+
filter: models.ForeignKey = models.ForeignKey(
1919
'DescriptedFilter',
2020
on_delete=models.CASCADE,
2121
related_name='filter_fields'
2222
)
23-
filter_field = models.CharField(help_text=_('Filter field'), max_length=256)
24-
description = models.TextField(help_text=_('Filter field description'), blank=True, null=True)
23+
filter_field: models.CharField = models.CharField(help_text=_('Filter field'), max_length=256)
24+
description: models.TextField = models.TextField(help_text=_('Filter field description'), blank=True, null=True)
2525

2626
class Meta:
2727
unique_together = ('filter', 'filter_field')
@@ -31,21 +31,21 @@ def __str__(self) -> str:
3131
Returns the name of the filter and the filter field
3232
that associated with description.
3333
"""
34-
return self.filter_field
34+
return str(self.filter_field)
3535

3636

3737
class DescriptedFilter(models.Model):
3838
"""
3939
A model representing a filter wich fields are descripted.
4040
"""
41-
filter_name = models.CharField(max_length=256, unique=True, choices=FILTERS_LIST)
41+
filter_name: models.CharField = models.CharField(max_length=256, unique=True, choices=FILTERS_LIST)
4242

4343
def __str__(self) -> str:
4444
"""
4545
Returns the name of the filter and the filter field
4646
that associated with description.
4747
"""
48-
return self.filter_name
48+
return str(self.filter_name)
4949

5050
def save(self, *args, **kwargs) -> None:
5151
"""
@@ -90,7 +90,7 @@ class Link(TimeStampedModel):
9090
"""
9191
A model representing a Link.
9292
"""
93-
link_type = models.CharField(
93+
link_type: models.CharField = models.CharField(
9494
help_text=_('Link type'),
9595
choices=LinkTypeChoices.choices,
9696
max_length=128

src/datasources/models.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@ class SourceSubdivision(TimeStampedModel):
77
"""
88
A model representing a source subdivision.
99
"""
10-
name = models.CharField(
10+
name: models.CharField = models.CharField(
1111
help_text=_('Name'),
1212
max_length=128,
1313
unique=True
1414
)
15-
display_name = models.CharField(
15+
display_name: models.CharField = models.CharField(
1616
help_text=_('Display Name'),
1717
max_length=128,
1818
unique=True
1919
)
20-
description = models.TextField(
20+
description: models.TextField = models.TextField(
2121
help_text=_('Source description'),
2222
max_length=1000,
2323
null=True,
2424
blank=True
2525
)
26-
db_source = models.CharField(
26+
db_source: models.CharField = models.CharField(
2727
help_text=_('DB Source'),
2828
max_length=128,
2929
)
30-
links = models.ManyToManyField(
30+
links: models.ManyToManyField = models.ManyToManyField(
3131
'base.Link',
3232
help_text=_('Source Subdivision links'),
3333
related_name="source_subdivisions"
3434
)
35-
data_source = models.ForeignKey(
35+
data_source: models.ForeignKey = models.ForeignKey(
3636
'datasources.DataSource',
3737
related_name='source_subdivisions',
3838
help_text=_('Source Subdivision'),
@@ -49,35 +49,35 @@ def __str__(self) -> str:
4949
:return: The name of the source subdivision as a string.
5050
:rtype: str
5151
"""
52-
return self.name
52+
return str(self.name)
5353

5454

5555
class DataSource(TimeStampedModel):
5656
"""
5757
A model representing a data source.
5858
"""
5959

60-
name = models.CharField(
60+
name: models.CharField = models.CharField(
6161
help_text=_('Name'),
6262
max_length=128,
6363
unique=True
6464
)
65-
display_name = models.CharField(
65+
display_name: models.CharField = models.CharField(
6666
help_text=_('Display Name'),
6767
max_length=128,
6868
unique=True
6969
)
70-
description = models.TextField(
70+
description: models.TextField = models.TextField(
7171
help_text=_('Source description'),
7272
max_length=1000,
7373
null=True,
7474
blank=True
7575
)
76-
source_license = models.CharField(
76+
source_license: models.CharField = models.CharField(
7777
help_text=_('License'),
7878
max_length=128
7979
)
80-
links = models.ManyToManyField(
80+
links: models.ManyToManyField = models.ManyToManyField(
8181
'base.Link',
8282
help_text=_('DataSource links'),
8383
related_name="data_sources"
@@ -93,4 +93,4 @@ def __str__(self) -> str:
9393
:return: The name of the data source as a string.
9494
:rtype: str
9595
"""
96-
return self.name
96+
return str(self.name)

src/docs/source/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
'sphinx.ext.autodoc',
2626
]
2727

28-
templates_path = ['_templates']
29-
exclude_patterns = []
28+
templates_path: list[str] = ['_templates']
29+
exclude_patterns: list = []
3030

3131

3232
# -- Options for HTML output -------------------------------------------------
3333
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3434

3535
html_theme = "sphinx_rtd_theme"
36-
html_static_path = ['_static']
36+
html_static_path: list[str] = ['_static']

src/signal_documentation/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
}
159159

160160

161-
PAGE_SIZE = os.environ.get('PAGE_SIZE', 10)
161+
PAGE_SIZE: int = int(os.environ.get('PAGE_SIZE', 10))
162162

163163

164164
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"

src/signals/filters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def filter_search(self, queryset, name, value) -> Any:
100100
query &= item
101101
queries.append(query)
102102

103-
query: Q = queries.pop()
103+
query = queries.pop()
104104

105105
for item in queries:
106106
query |= item

src/signals/forms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Meta:
8181
}),
8282
}
8383

84-
def __init__(self, *args, **kwargs):
84+
def __init__(self, *args, **kwargs) -> None:
8585
"""
8686
Initialize the form.
8787
"""
@@ -91,4 +91,4 @@ def __init__(self, *args, **kwargs):
9191
for field_name, field in self.fields.items():
9292
field.required = False
9393
field.help_text = ''
94-
field.label = False
94+
field.label = ''

0 commit comments

Comments
 (0)