Use ruff pyright and ty for linting

This commit is contained in:
Nick Sweeting
2026-03-15 19:43:59 -07:00
parent 49436af869
commit 4756697a17
8 changed files with 125 additions and 64 deletions

View File

@@ -69,8 +69,9 @@ def config(*keys,
# Display core config sections
for config_section in CONFIGS.values():
if hasattr(config_section, 'toml_section_header'):
print(f'[grey53]\\[{config_section.toml_section_header}][/grey53]')
section_header = getattr(config_section, 'toml_section_header', '')
if isinstance(section_header, str) and section_header:
print(f'[grey53]\\[{section_header}][/grey53]')
else:
print('[grey53]\\[CONSTANTS] # (read-only)[/grey53]')

View File

@@ -33,7 +33,7 @@ def init(force: bool=False, quick: bool=False, install: bool=False) -> None:
from archivebox.config import CONSTANTS, VERSION, DATA_DIR
from archivebox.config.common import SERVER_CONFIG
from archivebox.config.collection import write_config_file
from archivebox.misc.legacy import parse_json_main_index, parse_json_links_details, SnapshotDict
from archivebox.misc.legacy import parse_json_main_index, parse_json_links_details
from archivebox.misc.db import apply_migrations
# if os.access(out_dir / CONSTANTS.JSON_INDEX_FILENAME, os.F_OK):

View File

@@ -121,13 +121,15 @@ def server(runserver_args: Iterable[str]=(SERVER_CONFIG.BIND_ADDR,),
supervisor = get_existing_supervisord_process()
if supervisor:
daphne_proc = get_worker(supervisor, 'worker_daphne')
daphne_state = daphne_proc.get('statename') if isinstance(daphne_proc, dict) else None
# If daphne is already running, error out
if daphne_proc and daphne_proc.get('statename') == 'RUNNING':
if daphne_state == 'RUNNING':
orchestrator_proc = get_worker(supervisor, 'worker_orchestrator')
orchestrator_state = orchestrator_proc.get('statename') if isinstance(orchestrator_proc, dict) else None
print('[red][X] Error: ArchiveBox server is already running[/red]')
print(f' [green]√[/green] Web server (worker_daphne) is RUNNING on [deep_sky_blue4][link=http://{host}:{port}]http://{host}:{port}[/link][/deep_sky_blue4]')
if orchestrator_proc and orchestrator_proc.get('statename') == 'RUNNING':
if orchestrator_state == 'RUNNING':
print(' [green]√[/green] Background worker (worker_orchestrator) is RUNNING')
print()
print('[yellow]To stop the existing server, run:[/yellow]')

View File

@@ -152,7 +152,7 @@ def version(quiet: bool=False,
prnt('[deep_sky_blue3][i] Code locations:[/deep_sky_blue3]')
try:
for name, path in get_code_locations().items():
if isinstance(path, dict):
if isinstance(name, str) and isinstance(path, dict):
prnt(printable_folder_status(name, path), overflow='ignore', crop=False)
except Exception as e:
prnt(f' [red]Error getting code locations: {e}[/red]')
@@ -162,7 +162,7 @@ def version(quiet: bool=False,
prnt('[bright_yellow][i] Data locations:[/bright_yellow]')
try:
for name, path in get_data_locations().items():
if isinstance(path, dict):
if isinstance(name, str) and isinstance(path, dict):
prnt(printable_folder_status(name, path), overflow='ignore', crop=False)
except Exception as e:
prnt(f' [red]Error getting data locations: {e}[/red]')