Skip to content

Commit

Permalink
chore(types): check for return Any
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Jan 3, 2024
1 parent ba4d368 commit 8596a65
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ strict = true
# Scaling back on some of the strictness for now
disallow_any_generics = false
disallow_subclassing_any = false
warn_return_any = false

[[tool.mypy.overrides]]
module = ["fastjsonschema"]
Expand Down
8 changes: 4 additions & 4 deletions src/validate_pyproject/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from importlib.resources import files

def read_text(package: Union[str, ModuleType], resource: str) -> str:
return files(package).joinpath(resource).read_text(encoding="utf-8")
return files(package).joinpath(resource).read_text(encoding="utf-8") # type: ignore[no-any-return]

except ImportError: # pragma: no cover
from importlib.resources import read_text
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self, plugins: Sequence["PluginProtocol"] = ()):
# (which part of the TOML, who defines, schema)

top_level = typing.cast(dict, load(TOP_LEVEL_SCHEMA)) # Make it mutable
self._spec_version = top_level["$schema"]
self._spec_version: str = top_level["$schema"]
top_properties = top_level["properties"]
tool_properties = top_properties["tool"].setdefault("properties", {})

Expand All @@ -115,10 +115,10 @@ def __init__(self, plugins: Sequence["PluginProtocol"] = ()):
tool_properties[plugin.tool] = {"$ref": sref}
self._schemas[sid] = (f"tool.{plugin.tool}", plugin.id, plugin.schema)

self._main_id = sid = top_level["$id"]
self._main_id: str = top_level["$id"]
main_schema = Schema(top_level)
origin = f"{__name__} - build metadata"
self._schemas[sid] = ("<$ROOT>", origin, main_schema)
self._schemas[self._main_id] = ("<$ROOT>", origin, main_schema)

@property
def spec_version(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions src/validate_pyproject/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ def parse_args(
params = vars(parser.parse_args(args))
enabled = params.pop("enable", ())
disabled = params.pop("disable", ())
params["plugins"] = select_plugins(plugins, enabled, disabled)
params["tool"] = params["tool"] or []
params["store"] = params["store"] or ""
return params_class(**params) # type: ignore[call-overload]
params["plugins"] = select_plugins(plugins, enabled, disabled)
return params_class(**params) # type: ignore[call-overload, no-any-return]


def select_plugins(
Expand Down
2 changes: 1 addition & 1 deletion src/validate_pyproject/error_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _ErrorFormatting:
def __init__(self, ex: JsonSchemaValueException):
self.ex = ex
self.name = f"`{self._simplify_name(ex.name)}`"
self._original_message = self.ex.message.replace(ex.name, self.name)
self._original_message: str = self.ex.message.replace(ex.name, self.name)
self._summary = ""
self._details = ""

Expand Down
2 changes: 1 addition & 1 deletion src/validate_pyproject/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _download_classifiers() -> str:
with urlopen(url, context=context) as response: # noqa: S310 (audit URLs)
headers = Message()
headers["content_type"] = response.getheader("content-type", "text/plain")
return response.read().decode(headers.get_param("charset", "utf-8"))
return response.read().decode(headers.get_param("charset", "utf-8")) # type: ignore[no-any-return]


class _TroveClassifier:
Expand Down
2 changes: 1 addition & 1 deletion src/validate_pyproject/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, *, tool: str, schema: Schema, fragment: str = ""):
self.help_text = f"{tool} <external>"

@classmethod
def from_url(cls, tool: str, url: str):
def from_url(cls, tool: str, url: str) -> "Self":
fragment, schema = load_from_uri(url)
return cls(tool=tool, schema=schema, fragment=fragment)

Expand Down

0 comments on commit 8596a65

Please sign in to comment.