fix(config-editor): pyright errors

This commit is contained in:
Benexl
2025-10-26 22:37:57 +03:00
parent a5e99122f5
commit 642e77f601

View File

@@ -2,6 +2,7 @@ import textwrap
from pathlib import Path
from typing import Any, Literal, get_args, get_origin
# TODO: should we maintain a separate dependency for InquirerPy or write our own simple prompt system?
from InquirerPy import inquirer
from InquirerPy.validator import NumberValidator
from pydantic import BaseModel
@@ -28,7 +29,7 @@ class InteractiveConfigEditor:
if not isinstance(section_model, BaseModel):
continue
if not inquirer.confirm(
if not inquirer.confirm( # pyright: ignore[reportPrivateImportUsage]
message=f"Configure '{section_name.title()}' settings?",
default=True,
).execute():
@@ -83,14 +84,14 @@ class InteractiveConfigEditor:
# Boolean fields
if field_type is bool:
return inquirer.confirm(
return inquirer.confirm( # pyright: ignore[reportPrivateImportUsage]
message=message, default=current_value, long_instruction=help_text
)
# Literal (Choice) fields
if hasattr(field_type, "__origin__") and get_origin(field_type) is Literal:
choices = list(get_args(field_type))
return inquirer.select(
return inquirer.select( # pyright: ignore[reportPrivateImportUsage]
message=message,
choices=choices,
default=current_value,
@@ -99,7 +100,7 @@ class InteractiveConfigEditor:
# Numeric fields
if field_type is int:
return inquirer.number(
return inquirer.number( # pyright: ignore[reportPrivateImportUsage]
message=message,
default=int(current_value),
long_instruction=help_text,
@@ -110,7 +111,7 @@ class InteractiveConfigEditor:
validate=NumberValidator(),
)
if field_type is float:
return inquirer.number(
return inquirer.number( # pyright: ignore[reportPrivateImportUsage]
message=message,
default=float(current_value),
float_allowed=True,
@@ -120,7 +121,7 @@ class InteractiveConfigEditor:
# Path fields
if field_type is Path:
# Use text prompt for paths to allow '~' expansion, as FilePathPrompt can be tricky
return inquirer.text(
return inquirer.text( # pyright: ignore[reportPrivateImportUsage]
message=message, default=str(current_value), long_instruction=help_text
)
@@ -128,13 +129,13 @@ class InteractiveConfigEditor:
if field_type is str:
# Check for 'examples' to provide choices
if hasattr(field_info, "examples") and field_info.examples:
return inquirer.fuzzy(
return inquirer.fuzzy( # pyright: ignore[reportPrivateImportUsage]
message=message,
choices=field_info.examples,
default=str(current_value),
long_instruction=help_text,
)
return inquirer.text(
return inquirer.text( # pyright: ignore[reportPrivateImportUsage]
message=message, default=str(current_value), long_instruction=help_text
)