Skip to content

Commit

Permalink
Fix typing errors
Browse files Browse the repository at this point in the history
In the force case, the metadata could be None regardless.
In that case we can just disregard any warnings
  • Loading branch information
sosthene-nitrokey committed Oct 22, 2024
1 parent 384eb6a commit 62c5de1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pynitrokey/cli/nk3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def set_config(ctx: Context, key: str, value: str, force: bool, dry_run: bool) -
support_hint=False,
)

if not force and not field_metadata.ty.is_valid(value):
if not force and field_metadata is not None and not field_metadata.ty.is_valid(value):
raise CliException(
f"Invalid config value for {field}: expected {field_metadata.ty}, got `{value}`. Unknown config values can only be set if the --force/-f flag is set. Aborting.",
support_hint=False,
Expand All @@ -212,28 +212,28 @@ def set_config(ctx: Context, key: str, value: str, force: bool, dry_run: bool) -
"user data currently stored on the device.",
file=sys.stderr,
)
elif field_metadata.destructive:
elif field_metadata is not None and field_metadata.destructive:
print(
"This configuration value may delete data on your device",
file=sys.stderr,
)

if field_metadata.destructive:
if field_metadata is not None and field_metadata.destructive:
click.confirm("Do you want to continue anyway?", abort=True)

if dry_run:
print("Stopping dry run.", file=sys.stderr)
raise click.Abort()

if field_metadata.requires_touch_confirmation:
if field_metadata is not None and field_metadata.requires_touch_confirmation:
print(
"Press the touch button to confirm the configuration change.",
file=sys.stderr,
)

device.admin.set_config(key, value)

if field_metadata.requires_reboot:
if field_metadata is not None and field_metadata.requires_reboot:
print("Rebooting device to apply config change.")
device.reboot()

Expand Down

0 comments on commit 62c5de1

Please sign in to comment.