diff --git a/.gitignore b/.gitignore index f3d5cc3..46d2341 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.pyre/ example/venv # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ace175d..0e7cb07 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,8 @@ repos: # pre-commit's default_language_version, see # https://pre-commit.com/#top_level-default_language_version language_version: python3.11 + + - repo: https://github.com/fsouza/pre-commit-pyre-check + rev: '199dc59' # Use the sha / tag you want to point at + hooks: + - id: pyre-check diff --git a/.pyre_configuration b/.pyre_configuration new file mode 100644 index 0000000..591ec25 --- /dev/null +++ b/.pyre_configuration @@ -0,0 +1,15 @@ +{ + "source_directories": [ + "." + ], + "search_path": [ + "env/lib/python3.11/site-packages/" + ], + "ignore_all_errors":[ + "*env*/*", + "example/venv/*", +"build/*", +"example/*" + + ] +} diff --git a/mfa/Common.py b/mfa/Common.py index 7d45373..9137ea9 100644 --- a/mfa/Common.py +++ b/mfa/Common.py @@ -4,7 +4,7 @@ from django.core.mail import EmailMessage try: from django.urls import reverse except: - from django.core.urlresolver import reverse + from django.core.urlresolver import reverse # pyre-ignore[21] def send(to, subject, body): diff --git a/mfa/Email.py b/mfa/Email.py index 02094ac..570a41f 100644 --- a/mfa/Email.py +++ b/mfa/Email.py @@ -40,7 +40,7 @@ def start(request): from django.http import HttpResponseRedirect try: - from django.core.urlresolvers import reverse + from django.core.urlresolvers import reverse # pyre-ignore[21] except: from django.urls import reverse if ( diff --git a/mfa/middleware.py b/mfa/middleware.py index 4acc51f..304edf2 100644 --- a/mfa/middleware.py +++ b/mfa/middleware.py @@ -1,6 +1,10 @@ import time from django.http import HttpResponseRedirect -from django.core.urlresolvers import reverse + +try: + from django.core.urlresolvers import reverse # pyre-ignore[21] +except: + from django.urls import reverse from django.conf import settings diff --git a/mfa/migrations/0005_auto_20181115_2014.py b/mfa/migrations/0005_auto_20181115_2014.py index 55ed151..7e194fb 100644 --- a/mfa/migrations/0005_auto_20181115_2014.py +++ b/mfa/migrations/0005_auto_20181115_2014.py @@ -7,7 +7,7 @@ try: from django.db.models import JSONField except ImportError: try: - from jsonfield.fields import JSONField + from jsonfield.fields import JSONField # pyre-ignore[21] except ImportError: raise ImportError( "Can't find a JSONField implementation, please install jsonfield if django < 4.0" diff --git a/mfa/models.py b/mfa/models.py index 8abac40..a7a07f0 100644 --- a/mfa/models.py +++ b/mfa/models.py @@ -4,7 +4,7 @@ try: from django.db.models import JSONField except ModuleNotFoundError: try: - from jsonfield import JSONField + from jsonfield import JSONField # pyre-ignore[21] except ModuleNotFoundError: raise ModuleNotFoundError( "Can't find a JSONField implementation, please install jsonfield if django < 4.0" diff --git a/mfa/urls.py b/mfa/urls.py index 423b53c..5d9c413 100644 --- a/mfa/urls.py +++ b/mfa/urls.py @@ -5,7 +5,7 @@ from . import views, totp, U2F, TrustedDevice, helpers, FIDO2, Email, recovery try: from django.urls import re_path as url except: - from django.conf.urls import url + from django.conf.urls import url # pyre-ignore[21] urlpatterns = [ url(r"totp/start/", totp.start, name="start_new_otop"), url(r"totp/getToken", totp.getToken, name="get_new_otop"), diff --git a/mfa/views.py b/mfa/views.py index b7c1404..667d6f1 100644 --- a/mfa/views.py +++ b/mfa/views.py @@ -7,7 +7,7 @@ from .models import * try: from django.urls import reverse except: - from django.core.urlresolvers import reverse + from django.core.urlresolvers import reverse # pyre-ignore[21] from django.template.context_processors import csrf from django.template.context import RequestContext from django.conf import settings diff --git a/requirements.txt b/requirements.txt index 465a59e..f01bf78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ python-jose fido2 == 1.1.0 jsonLookup raven +pyre-check