Skip to content

Commit

Permalink
First steps with static type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
quique committed Sep 8, 2022
1 parent c32d70a commit 75f90fc
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 65 deletions.
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ verify_ssl = true
black = "*"
coverage = "*"
django-debug-toolbar = "*"
django-stubs = "*"
mypy = "*"
pre-commit = "*"
pylint = "*"
rope = "*"
types-bleach = "*"

[packages]
bleach = {extras = ["css"], version = "*"}
Expand Down
145 changes: 108 additions & 37 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions indo/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import datetime

from typing import Optional

from django.core.validators import FileExtensionValidator
from django.db import connection, models
from django.urls import reverse
Expand Down Expand Up @@ -658,7 +661,7 @@ def get_absolute_url(self):
def en_borrador(self):
return self.estado == 'BORRADOR'

def get_pp_coordinador_or_none(self, tipo):
def get_pp_coordinador_or_none(self, tipo) -> Optional[ParticipanteProyecto]:
"""Busca el coordinador o coordinador_2 del proyecto"""
try:
return self.participantes.get(tipo_participacion_id=tipo)
Expand Down Expand Up @@ -796,7 +799,7 @@ def get_up_gastos(cls, anyo):
datos_proyectos.insert(0, cabeceras)
return datos_proyectos

def get_unidad_planificacion(self):
def get_unidad_planificacion(self) -> Optional[str]:
"""Devuelve el ID de la Unidad de Planificación del proyecto
PIEC, PIPOUZ, PIET: UP del centro del proyecto
Expand Down
2 changes: 2 additions & 0 deletions mypy-django.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy_django_plugin]
ignore_missing_model_attributes = True
28 changes: 28 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[mypy]
# The mypy configuration file: <https://mypy.readthedocs.io/en/latest/config_file.html>
python_version = 3.10

check_untyped_defs = True
# disallow_any_explicit = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
ignore_errors = False
ignore_missing_imports = True
implicit_reexport = False
strict_optional = True
strict_equality = True
no_implicit_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
warn_no_return = True

plugins = mypy_django_plugin.main

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

[mypy-*.migrations.*]
ignore_errors = True
52 changes: 26 additions & 26 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
-i https://pypi.org/simple
asgiref==3.5.2
attrs==22.1.0
asgiref==3.5.2; python_version >= '3.7'
attrs==22.1.0; python_version >= '3.5'
bleach[css]==5.0.1
brotli==1.0.9
cached-property==1.5.2
certifi==2022.6.15
certifi==2022.6.15; python_version >= '3.6'
cffi==1.15.1
charset-normalizer==2.1.1
cryptography==37.0.4
cssselect2==0.6.0
defusedxml==0.7.1
charset-normalizer==2.1.1; python_version >= '3.6'
cryptography==38.0.1; python_version >= '3.6'
cssselect2==0.6.0; python_version >= '3.7'
defusedxml==0.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
django==4.1.1
django-annoying==0.10.6
django-crispy-forms==1.14.0
django-filter==22.1
django-render-block==0.9.1
django-render-block==0.9.1; python_version >= '3.6'
django-summernote==0.8.20.0
django-tables2==2.4.1
django-templated-email==3.0.0
fonttools[woff]==4.37.1
html5lib==1.1
fonttools[woff]==4.37.1; python_version >= '3.7'
html5lib==1.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
huey==2.4.3
idna==3.3
idna==3.3; python_version >= '3.5'
isodate==0.6.1
lxml==4.6.5
lxml==4.6.5; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
mysqlclient==2.1.1
oauthlib==3.2.0
pillow==9.2.0
platformdirs==2.5.2
pycparser==2.21
pydyf==0.2.0
pyjwt==2.4.0
oauthlib==3.2.0; python_version >= '3.6'
pillow==9.2.0; python_version >= '3.7'
platformdirs==2.5.2; python_version >= '3.7'
pycparser==2.21; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pydyf==0.2.0; python_version >= '3.7'
pyjwt==2.4.0; python_version >= '3.6'
pypandoc==1.8.1
pyphen==0.13.0
pyphen==0.13.0; python_version >= '3.7'
python-magic==0.4.27
python3-openid==3.2.0
python3-saml==1.14.0
pytz==2022.2.1
requests==2.28.1
requests==2.28.1; python_version >= '3.7' and python_version < '4'
requests-file==1.5.1
requests-oauthlib==1.3.1
requests-oauthlib==1.3.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
requests-toolbelt==0.9.1
six==1.16.0
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
social-auth-app-django==5.0.0
social-auth-core[saml]==4.3.0
sqlparse==0.4.2
sqlparse==0.4.2; python_version >= '3.5'
tablib==3.2.1
tinycss2==1.1.1
urllib3==1.26.12
tinycss2==1.1.1; python_version >= '3.6'
urllib3==1.26.12; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'
weasyprint==56.1
webencodings==0.5.1
xmlsec==1.3.13
xmlsec==1.3.13; python_version >= '3.5'
zeep==4.1.0
zopfli==0.2.1

0 comments on commit 75f90fc

Please sign in to comment.