nix fmt
All checks were successful
checks-impure / test (pull_request) Successful in 1m3s
checks / test (pull_request) Successful in 2m41s

This commit is contained in:
Luis Hebendanz 2023-12-19 18:02:06 +01:00
parent e0e7324876
commit a1575ec19c
2 changed files with 7 additions and 7 deletions

View File

@ -1,17 +1,16 @@
# Import the urllib.parse, enum and dataclasses modules # Import the urllib.parse, enum and dataclasses modules
import dataclasses import dataclasses
import urllib.parse import urllib.parse
import urllib.request
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, member from enum import Enum, member
from pathlib import Path from pathlib import Path
from typing import Self from typing import Self
import urllib.request
from .errors import ClanError from .errors import ClanError
def url_ok(url: str): def url_ok(url: str) -> None:
# Create a request object with the URL and the HEAD method # Create a request object with the URL and the HEAD method
req = urllib.request.Request(url, method="HEAD") req = urllib.request.Request(url, method="HEAD")
try: try:
@ -99,11 +98,11 @@ class ClanURI:
case ("http" | "https", _, _, _, _, _): case ("http" | "https", _, _, _, _, _):
self.scheme = ClanScheme.HTTP.value(self._components.geturl()) # type: ignore self.scheme = ClanScheme.HTTP.value(self._components.geturl()) # type: ignore
case ("file", "", path, "", "", "") | ("", "", path, "", "", ""): # type: ignore case ("file", "", path, "", "", "") | ("", "", path, "", "", ""): # type: ignore
self.scheme = ClanScheme.FILE.value(Path(path)) # type: ignore self.scheme = ClanScheme.FILE.value(Path(path))
case _: case _:
raise ClanError(f"Unsupported uri components: {comb}") raise ClanError(f"Unsupported uri components: {comb}")
def check_exits(self): def check_exits(self) -> None:
match self.scheme: match self.scheme:
case ClanScheme.FILE.value(path): case ClanScheme.FILE.value(path):
if not path.exists(): if not path.exists():
@ -114,9 +113,9 @@ class ClanURI:
def get_internal(self) -> str: def get_internal(self) -> str:
match self.scheme: match self.scheme:
case ClanScheme.FILE.value(path): case ClanScheme.FILE.value(path):
return str(path) # type: ignore return str(path)
case ClanScheme.HTTP.value(url): case ClanScheme.HTTP.value(url):
return url # type: ignore return url
case _: case _:
raise ClanError(f"Unsupported uri components: {self.scheme}") raise ClanError(f"Unsupported uri components: {self.scheme}")

View File

@ -30,6 +30,7 @@ warn_redundant_casts = true
disallow_untyped_calls = true disallow_untyped_calls = true
disallow_untyped_defs = true disallow_untyped_defs = true
no_implicit_optional = true no_implicit_optional = true
disable_error_code = ["has-type"]
exclude = "clan_cli.nixpkgs" exclude = "clan_cli.nixpkgs"
[[tool.mypy.overrides]] [[tool.mypy.overrides]]