Skip to content

Commit

Permalink
fix: use mypy.ignore_missing_imports instead of suppressing them ever…
Browse files Browse the repository at this point in the history
…ywhere manually (#238)
  • Loading branch information
yedpodtrzitko authored Jul 22, 2022
1 parent 2f78418 commit 278f1bd
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ lint:
isort --check --diff --project=spectree ${SOURCE_FILES}
black --check --diff ${SOURCE_FILES}
flake8 ${SOURCE_FILES} --count --show-source --statistics
mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --disable-error-code attr-defined ${SOURCE_FILES}
mypy --install-types --non-interactive ${SOURCE_FILES}

.PHONY: test doc
2 changes: 1 addition & 1 deletion examples/falcon_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from random import random
from wsgiref import simple_server

import falcon # type: ignore
import falcon
from pydantic import BaseModel, Field

from spectree import Response, SpecTree, Tag
Expand Down
2 changes: 1 addition & 1 deletion examples/starlette_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uvicorn # type: ignore
import uvicorn
from pydantic import BaseModel, Field
from starlette.applications import Starlette
from starlette.endpoints import HTTPEndpoint
Expand Down
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mypy]
ignore_missing_imports = true
show_error_codes = true
warn_unused_ignores = true
disable_error_code = attr-defined
4 changes: 2 additions & 2 deletions spectree/plugins/falcon_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class FalconPlugin(BasePlugin):
def __init__(self, spectree):
super().__init__(spectree)

from falcon import HTTP_400, HTTP_415, HTTPError # type: ignore
from falcon.routing.compiled import _FIELD_PATTERN # type: ignore
from falcon import HTTP_400, HTTP_415, HTTPError
from falcon.routing.compiled import _FIELD_PATTERN

# used to detect falcon 3.0 request media parse error
self.FALCON_HTTP_ERROR = HTTPError
Expand Down
3 changes: 2 additions & 1 deletion spectree/plugins/flask_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def validate(
before(request, response, req_validation_error, None)
if req_validation_error:
after(request, response, req_validation_error, None)
abort(response) # type: ignore
assert response # make mypy happy
abort(response)

result = func(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_plugin_falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
try:
from falcon import App
except ImportError:
from falcon import API as App # type: ignore
from falcon import API as App

import pytest
from falcon import testing
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin_falcon_asgi.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from random import randint

import pytest
from falcon import testing # type: ignore
from falcon import testing

from spectree import Response, SpecTree

from .common import JSON, Cookies, Headers, Query, Resp, StrDict, api_tag

pytest.importorskip("falcon", minversion="3.0.0", reason="Missing required Falcon 3.0")
from falcon.asgi import App # type: ignore # noqa: E402
from falcon.asgi import App # noqa: E402


def before_handler(req, resp, err, instance):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_spec.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
from falcon import App as FalconApp
except ImportError:
from falcon import API as FalconApp # type: ignore
from falcon import API as FalconApp

import pytest
from flask import Flask
Expand Down

0 comments on commit 278f1bd

Please sign in to comment.