Skip to content

Commit

Permalink
fix styles for newest version of mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
reallistic committed Oct 17, 2024
1 parent af24428 commit 0440d9c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ignore=snapshots
load-plugins=pylint.extensions.bad_builtin, pylint.extensions.mccabe

[MESSAGES CONTROL]
disable=C0103, C0111, C0209, C0412, I0011, R0101, R0801, R0901, R0902, R0903, R0912, R0913, R0914, R0915, R1260, W0105, W0231, W0511, W0621, W0703
disable=C0103, C0111, C0209, C0412, I0011, R0101, R0801, R0901, R0902, R0903, R0912, R0913, R0914, R0915, R0917, R1260, W0105, W0231, W0511, W0621, W0703

[SIMILARITIES]
ignore-imports=yes
4 changes: 4 additions & 0 deletions ariadne/contrib/tracing/copy_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ def copy_args_for_tracing(value: Any) -> Any:


def repr_upload_file(upload_file: Union[UploadFile, File]) -> str:
filename: Union[str, None, bytes]
if isinstance(upload_file, File):
filename = upload_file.file_name
else:
filename = upload_file.filename

if isinstance(filename, bytes):
filename = filename.decode()

mime_type: Union[str, None]

if isinstance(upload_file, File):
Expand Down
4 changes: 4 additions & 0 deletions ariadne/contrib/tracing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def copy_args_for_tracing(value: Any) -> Any:


def repr_upload_file(upload_file: Union[UploadFile, File]) -> str:
filename: Union[str, None, bytes]
if isinstance(upload_file, File):
filename = upload_file.file_name
else:
filename = upload_file.filename

if isinstance(filename, bytes):
filename = filename.decode()

mime_type: Union[str, None]

if isinstance(upload_file, File):
Expand Down
3 changes: 2 additions & 1 deletion ariadne/load_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path
from typing import Generator, Union

from graphql import parse
Expand Down Expand Up @@ -27,7 +28,7 @@ def load_schema_from_path(path: Union[str, os.PathLike]) -> str:
if os.path.isdir(path):
schema_list = [read_graphql_file(f) for f in sorted(walk_graphql_files(path))]
return "\n".join(schema_list)
return read_graphql_file(os.path.abspath(path))
return read_graphql_file(Path(path).resolve())


def walk_graphql_files(path: Union[str, os.PathLike]) -> Generator[str, None, None]:
Expand Down
7 changes: 5 additions & 2 deletions ariadne/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from multipart import parse_form
except ImportError:

def parse_form(*_args, **_kwargs):
def parse_form(*_args, **_kwargs): # type: ignore
raise NotImplementedError(
"WSGI file uploads requires 'python-multipart' library."
)
Expand Down Expand Up @@ -668,8 +668,11 @@ def parse_multipart_request(environ: dict) -> "FormData":
headers = {"Content-Type": content_type}
form_data = FormData(content_type)

# Silence mypy error for this incorrect type.
# parse_fprm defines the type as dict[str, bytes] but works with
# dict[str, Optional[str | bytes]] and will throw ValueError if Content-Type is None.
parse_form(
headers,
headers, # type: ignore
environ["wsgi.input"],
form_data.on_field,
form_data.on_file,
Expand Down

0 comments on commit 0440d9c

Please sign in to comment.