Skip to content

Commit

Permalink
Change related to output of enums and literals
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr committed Oct 22, 2024
1 parent 93c0326 commit b4e0660
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/gallia/commands/scan/uds/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from itertools import product

from gallia.command import UDSScanner
from gallia.command.config import AutoInt, Field, HexBytes, Ranges, Ranges2D
from gallia.command.config import AutoInt, EnumArg, Field, HexBytes, Ranges, Ranges2D
from gallia.command.uds import UDSScannerConfig
from gallia.log import get_logger
from gallia.services.uds.core.client import UDSRequestConfig
Expand All @@ -28,7 +28,7 @@ class ScanIdentifiersConfig(UDSScannerConfig):
payload: HexBytes | None = Field(
None, description="Payload which will be appended for each request as hex string"
)
service: UDSIsoServices = Field(
service: EnumArg[UDSIsoServices] = Field(
UDSIsoServices.ReadDataByIdentifier,
description="\n Service (ID) to scan; defaults to ReadDataByIdentifier;\n currently supported:\n 0x27 Security Access;\n 0x22 Read Data By Identifier;\n 0x2e Write Data By Identifier;\n 0x31 Routine Control;\n ",
)
Expand Down
2 changes: 1 addition & 1 deletion vendor/pydantic-argparse/pydantic_argparse/parsers/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse_field(
enum_type = cast(Type[enum.Enum], field.info.annotation)

# Determine Argument Properties
metavar = f"{{{', '.join(f'{e.value}({e.name})' for e in enum_type)}}}"
metavar = f"{{{', '.join(f'{e.value}' for e in enum_type)}}}"
action = argparse._StoreAction

# Add Enum Field
Expand Down
11 changes: 1 addition & 10 deletions vendor/pydantic-argparse/pydantic_argparse/parsers/literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,7 @@ def parse_field(
# Extract Choices
choices = get_args(field.info.annotation)

# Determine Argument Properties
choice_reprs = []

for c in choices:
if isinstance(c, Enum):
choice_reprs.append(f"{c.name}({c.value})")
else:
choice_reprs.append(str(c))

metavar = f"{{{', '.join(choice_reprs)}}}"
metavar = f"{{{', '.join(str(c) for c in choices)}}}"

action = argparse._StoreAction

Expand Down

0 comments on commit b4e0660

Please sign in to comment.