Merge pull request 'ruff: enable upgrade rule checks' (#200) from Mic92-main into main
All checks were successful
checks-impure / test (push) Successful in 3s
checks / test (push) Successful in 16s

This commit is contained in:
clan-bot 2023-08-27 08:53:49 +00:00
commit ab90244486
6 changed files with 10 additions and 10 deletions

View File

@ -180,9 +180,9 @@ def process_args(
def register_parser(
parser: argparse.ArgumentParser,
optionsFile: Optional[Union[str, Path]] = os.environ.get("CLAN_OPTIONS_FILE"),
options_file: Optional[Union[str, Path]] = os.environ.get("CLAN_OPTIONS_FILE"),
) -> None:
if not optionsFile:
if not options_file:
# use nix eval to evaluate .#clanOptions
# this will give us the evaluated config with the options attribute
proc = subprocess.run(
@ -200,7 +200,7 @@ def register_parser(
with open(file) as f:
options = json.load(f)
else:
with open(optionsFile) as f:
with open(options_file) as f:
options = json.load(f)
return _register_parser(parser, options)

View File

@ -50,7 +50,7 @@ class CommandFormatter(logging.Formatter):
self.hostnames: List[str] = []
self.hostname_color_offset = 1 # first host shouldn't get agressive red
def formatMessage(self, record: logging.LogRecord) -> str:
def format(self, record: logging.LogRecord) -> str:
colorcode = 0
if record.levelno == logging.ERROR:
colorcode = 31 # red
@ -68,7 +68,7 @@ class CommandFormatter(logging.Formatter):
setattr(record, "prefix_color", prefix_color)
setattr(record, "color_reset", color_reset)
return super().formatMessage(record)
return super().format(record)
def hostname_colorcode(self, hostname: str) -> int:
try:

View File

@ -33,7 +33,7 @@ def ssh(
subprocess.run(cmd)
def qrcode_scan(pictureFile: str) -> str:
def qrcode_scan(picture_file: str) -> str:
return (
subprocess.run(
nix_shell(
@ -42,7 +42,7 @@ def qrcode_scan(pictureFile: str) -> str:
"zbarimg",
"--quiet",
"--raw",
pictureFile,
picture_file,
],
),
stdout=subprocess.PIPE,

View File

@ -13,7 +13,7 @@ router = APIRouter()
async def root(path_name: str) -> Response:
if path_name == "":
path_name = "index.html"
filename = Path(os.path.normpath((asset_path() / path_name)))
filename = Path(os.path.normpath(asset_path() / path_name))
if not filename.is_relative_to(asset_path()):
# prevent directory traversal

View File

@ -20,7 +20,7 @@ def try_bind_port(port: int) -> bool:
tcp.bind(("127.0.0.1", port))
udp.bind(("127.0.0.1", port))
return True
except socket.error:
except OSError:
return False

View File

@ -46,7 +46,7 @@ ignore_missing_imports = true
[tool.ruff]
line-length = 88
select = [ "E", "F", "I" ]
select = [ "E", "F", "I", "U", "N"]
ignore = [ "E501" ]
[tool.black]