Skip to content

Okrs24 138 fix mypy issues #96

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

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ celery = {version = "*", extras = ["redis"]}
flower = "*"
django-htmx = "*"
gunicorn = "*"
types-requests = "*"

[dev-packages]
flake8 = "*"
Expand Down
330 changes: 173 additions & 157 deletions Pipfile.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ plugins =

[mypy.plugins.django-stubs]
django_settings_module = signal_documentation.settings

[mypy-*.migrations.*]
ignore_errors = True

[mypy-signal_documentation.settings.*]
ignore_errors = True

[mypy-*.tests.*]
ignore_errors = True
2 changes: 1 addition & 1 deletion src/base/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def filters_descriptions(request) -> dict[str, list[dict[str, Any]]]:
"""
descripted_filters = DescriptedFilter.objects.all()

results: dict[str, dict[dict[str, dict[str, str]]]] = {
results: dict = {
'filters_descriptions': {
split_class_name(str(df.filter_name))[-1]: df.descriptions
} for df in descripted_filters
Expand Down
14 changes: 7 additions & 7 deletions src/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class DescriptedFilterField(models.Model):
"""
A model representing a filter field that is descripted.
"""
filter = models.ForeignKey(
filter: models.ForeignKey = models.ForeignKey(
'DescriptedFilter',
on_delete=models.CASCADE,
related_name='filter_fields'
)
filter_field = models.CharField(help_text=_('Filter field'), max_length=256)
description = models.TextField(help_text=_('Filter field description'), blank=True, null=True)
filter_field: models.CharField = models.CharField(help_text=_('Filter field'), max_length=256)
description: models.TextField = models.TextField(help_text=_('Filter field description'), blank=True, null=True)

class Meta:
unique_together = ('filter', 'filter_field')
Expand All @@ -31,21 +31,21 @@ def __str__(self) -> str:
Returns the name of the filter and the filter field
that associated with description.
"""
return self.filter_field
return str(self.filter_field)


class DescriptedFilter(models.Model):
"""
A model representing a filter wich fields are descripted.
"""
filter_name = models.CharField(max_length=256, unique=True, choices=FILTERS_LIST)
filter_name: models.CharField = models.CharField(max_length=256, unique=True, choices=FILTERS_LIST)

def __str__(self) -> str:
"""
Returns the name of the filter and the filter field
that associated with description.
"""
return self.filter_name
return str(self.filter_name)

def save(self, *args, **kwargs) -> None:
"""
Expand Down Expand Up @@ -90,7 +90,7 @@ class Link(TimeStampedModel):
"""
A model representing a Link.
"""
link_type = models.CharField(
link_type: models.CharField = models.CharField(
help_text=_('Link type'),
choices=LinkTypeChoices.choices,
max_length=128
Expand Down
26 changes: 13 additions & 13 deletions src/datasources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ class SourceSubdivision(TimeStampedModel):
"""
A model representing a source subdivision.
"""
name = models.CharField(
name: models.CharField = models.CharField(
help_text=_('Name'),
max_length=128,
unique=True
)
display_name = models.CharField(
display_name: models.CharField = models.CharField(
help_text=_('Display Name'),
max_length=128,
unique=True
)
description = models.TextField(
description: models.TextField = models.TextField(
help_text=_('Source description'),
max_length=1000,
null=True,
blank=True
)
db_source = models.CharField(
db_source: models.CharField = models.CharField(
help_text=_('DB Source'),
max_length=128,
)
links = models.ManyToManyField(
links: models.ManyToManyField = models.ManyToManyField(
'base.Link',
help_text=_('Source Subdivision links'),
related_name="source_subdivisions"
)
data_source = models.ForeignKey(
data_source: models.ForeignKey = models.ForeignKey(
'datasources.DataSource',
related_name='source_subdivisions',
help_text=_('Source Subdivision'),
Expand All @@ -49,35 +49,35 @@ def __str__(self) -> str:
:return: The name of the source subdivision as a string.
:rtype: str
"""
return self.name
return str(self.name)


class DataSource(TimeStampedModel):
"""
A model representing a data source.
"""

name = models.CharField(
name: models.CharField = models.CharField(
help_text=_('Name'),
max_length=128,
unique=True
)
display_name = models.CharField(
display_name: models.CharField = models.CharField(
help_text=_('Display Name'),
max_length=128,
unique=True
)
description = models.TextField(
description: models.TextField = models.TextField(
help_text=_('Source description'),
max_length=1000,
null=True,
blank=True
)
source_license = models.CharField(
source_license: models.CharField = models.CharField(
help_text=_('License'),
max_length=128
)
links = models.ManyToManyField(
links: models.ManyToManyField = models.ManyToManyField(
'base.Link',
help_text=_('DataSource links'),
related_name="data_sources"
Expand All @@ -93,4 +93,4 @@ def __str__(self) -> str:
:return: The name of the data source as a string.
:rtype: str
"""
return self.name
return str(self.name)
6 changes: 3 additions & 3 deletions src/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
'sphinx.ext.autodoc',
]

templates_path = ['_templates']
exclude_patterns = []
templates_path: list[str] = ['_templates']
exclude_patterns: list = []


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

html_theme = "sphinx_rtd_theme"
html_static_path = ['_static']
html_static_path: list[str] = ['_static']
2 changes: 1 addition & 1 deletion src/signal_documentation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
}


PAGE_SIZE = os.environ.get('PAGE_SIZE', 10)
PAGE_SIZE: int = int(os.environ.get('PAGE_SIZE', 10))


CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
Expand Down
2 changes: 1 addition & 1 deletion src/signals/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def filter_search(self, queryset, name, value) -> Any:
query &= item
queries.append(query)

query: Q = queries.pop()
query = queries.pop()

for item in queries:
query |= item
Expand Down
4 changes: 2 additions & 2 deletions src/signals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Meta:
}),
}

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
"""
Initialize the form.
"""
Expand All @@ -91,4 +91,4 @@ def __init__(self, *args, **kwargs):
for field_name, field in self.fields.items():
field.required = False
field.help_text = ''
field.label = False
field.label = ''
Loading
Loading