Skip to content

Commit 3db080c

Browse files
committed
fix: resolve remaining Pyright strict-mode errors
- Rename _USER_ALIASES to _user_aliases (mutable, not a constant) - Remove unnecessary isinstance(k, str) check after dict narrowing - Simplify config_diff_cli yaml loading to avoid partially-unknown types
1 parent 27e379c commit 3db080c

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/bernstein/cli/aliases.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
}
3434

3535
# Track which aliases are user-defined (populated at load time)
36-
_USER_ALIASES: dict[str, str] = {}
36+
_user_aliases: dict[str, str] = {}
3737

3838
_USER_ALIASES_PATH = Path.home() / ".bernstein" / "aliases.yaml"
3939

@@ -62,18 +62,18 @@ def _load_user_aliases() -> dict[str, str]:
6262
try:
6363
with open(_USER_ALIASES_PATH) as f:
6464
raw: object = yaml.safe_load(f) or {}
65-
data: dict[str, object] = raw if isinstance(raw, dict) else {}
66-
return {str(k): str(v) for k, v in data.items() if isinstance(k, str) and isinstance(v, str)}
65+
data = raw if isinstance(raw, dict) else {}
66+
return {k: str(v) for k, v in data.items() if isinstance(k, str) and isinstance(v, str)}
6767
except Exception:
6868
logger.debug("Failed to load user aliases from %s", _USER_ALIASES_PATH, exc_info=True)
6969
return {}
7070

7171

7272
def _merge_aliases() -> None:
7373
"""Merge user aliases into the global registry (user overrides built-in)."""
74-
global _USER_ALIASES
75-
_USER_ALIASES = _load_user_aliases()
76-
ALIASES.update(_USER_ALIASES)
74+
global _user_aliases # noqa: PLW0603
75+
_user_aliases = _load_user_aliases()
76+
ALIASES.update(_user_aliases)
7777

7878

7979
# Call at module load time
@@ -145,7 +145,7 @@ def aliases_cmd() -> None:
145145

146146
for alias, command in sorted(ALIASES.items()):
147147
desc = _descriptions.get(alias, "")
148-
source = "[cyan]user[/cyan]" if alias in _USER_ALIASES else "[dim]built-in[/dim]"
148+
source = "[cyan]user[/cyan]" if alias in _user_aliases else "[dim]built-in[/dim]"
149149
table.add_row(alias, command, source, desc)
150150

151151
console.print(table)

src/bernstein/cli/config_diff_cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ def _load_current_config() -> dict[str, object]:
1616
p = Path.cwd() / name
1717
if p.is_file():
1818
with open(p) as f:
19-
raw: object = yaml.safe_load(f) or {}
20-
data: dict[str, object] = raw if isinstance(raw, dict) else {}
21-
return data
19+
raw = yaml.safe_load(f)
20+
if isinstance(raw, dict):
21+
return dict(raw)
22+
return {}
2223
return {}
2324

2425

0 commit comments

Comments
 (0)