Skip to content

Commit 8e04871

Browse files
committed
Add type annotation to get_mercurial_default_options_dict
1 parent 4364049 commit 8e04871

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/tool_shed/webapp/controllers/repository.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import string
55
import tempfile
66
from datetime import date
7+
from typing import Any
78

89
from mercurial import (
910
mdiff,
@@ -72,11 +73,11 @@
7273
malicious_error_can_push = " Correct this changeset as soon as possible, it potentially produces malicious behavior or contains inappropriate content."
7374

7475

75-
def get_mercurial_default_options_dict(command):
76+
def get_mercurial_default_options_dict(command: str) -> dict[str, Any]:
7677
"""Get default parameters for a mercurial command."""
7778
# Use mdiff.diffopts defaults directly instead of introspecting command table
7879
# (the old cmdutil.findpossible API was removed in Mercurial 7.2)
79-
if command == b"diff":
80+
if command == "diff":
8081
# Convert byte keys to strings but preserve value types (int, bool)
8182
# as mdiff.diffopts expects properly typed values
8283
return {(k.decode("utf-8") if isinstance(k, bytes) else k): v for k, v in mdiff.diffopts.defaults.items()}
@@ -2365,7 +2366,7 @@ def view_changeset(self, trans, id, ctx_str, **kwd):
23652366
ctx_child = None
23662367
diffs = []
23672368
# Get default diff options with string keys and properly typed values
2368-
options_dict = get_mercurial_default_options_dict(b"diff")
2369+
options_dict = get_mercurial_default_options_dict("diff")
23692370
options_dict["maxfile"] = basic_util.MAXDIFFSIZE
23702371
options_dict["maxtotal"] = basic_util.MAXDIFFSIZE
23712372
diffopts = mdiff.diffopts(**options_dict)

0 commit comments

Comments
 (0)