Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated value values / arguments on CLI help message #675

Open
jack-mcivor opened this issue Sep 10, 2023 · 2 comments
Open

Duplicated value values / arguments on CLI help message #675

jack-mcivor opened this issue Sep 10, 2023 · 2 comments

Comments

@jack-mcivor
Copy link

jack-mcivor commented Sep 10, 2023

Minor, but I noticed that the checks are listed twice, once for the -e option and again for the --enable option. This makes the help message quite unwieldy.

pyanalyze -h
...
  -e {bad_star_import,cant_import,unexpected_node,undefined_name,undefined_attribute,attribute_is_never_set,duplicate_dict_key,unhashable_key,bad_unpack,unsupported_operation,not_callable,incompatible_call,method_first_arg,bad_super_call,impure_async_call,unnecessary_yield,class_variable_redefinition,bad_global,condition_always_true,inference_failure,bad_format_string,yield_without_value,invalid_method_return_type,missing_asynq,bad_exception,bad_async_yield,add_import,duplicate_yield,yield_in_comprehension,use_floor_div,task_needs_yield,mixing_bytes_and_text,bad_except_handler,implicit_non_ascii_string,missing_await,unused_variable,bad_nonlocal,non_boolean_in_boolean_context,use_fstrings,import_failed,unused_ignore,possibly_undefined_name,missing_f,incompatible_return_value,incompatible_argument,incompatible_default,internal_error,bad_yield_from,incompatible_assignment,invalid_typeddict_key,invalid_annotation,bare_ignore,duplicate_enum_member,missing_return_annotation,missing_parameter_annotation,type_always_true,value_always_true,type_does_not_support_bool,missing_return,no_return_may_return,implicit_reexport,invalid_context_manager,suggested_return_type,suggested_parameter_type,incompatible_override,impossible_pattern,bad_match,bad_evaluator,implicit_any,already_declared,invalid_annotated_assignment,unused_assignment,incompatible_yield,invalid_import,too_many_positional_args,deprecated,invalid_override_decorator,override_does_not_override}, \
  --enable {bad_star_import,cant_import,unexpected_node,undefined_name,undefined_attribute,attribute_is_never_set,duplicate_dict_key,unhashable_key,bad_unpack,unsupported_operation,not_callable,incompatible_call,method_first_arg,bad_super_call,impure_async_call,unnecessary_yield,class_variable_redefinition,bad_global,condition_always_true,inference_failure,bad_format_string,yield_without_value,invalid_method_return_type,missing_asynq,bad_exception,bad_async_yield,add_import,duplicate_yield,yield_in_comprehension,use_floor_div,task_needs_yield,mixing_bytes_and_text,bad_except_handler,implicit_non_ascii_string,missing_await,unused_variable,bad_nonlocal,non_boolean_in_boolean_context,use_fstrings,import_failed,unused_ignore,possibly_undefined_name,missing_f,incompatible_return_value,incompatible_argument,incompatible_default,internal_error,bad_yield_from,incompatible_assignment,invalid_typeddict_key,invalid_annotation,bare_ignore,duplicate_enum_member,missing_return_annotation,missing_parameter_annotation,type_always_true,value_always_true,type_does_not_support_bool,missing_return,no_return_may_return,implicit_reexport,invalid_context_manager,suggested_return_type,suggested_parameter_type,incompatible_override,impossible_pattern,bad_match,bad_evaluator,implicit_any,already_declared,invalid_annotated_assignment,unused_assignment,incompatible_yield,invalid_import,too_many_positional_args,deprecated,invalid_override_decorator,override_does_not_override}
...

Furthermore, I would suggest perhaps not duplicating the full list of checks across the --enable and --disable option

(version 0.10.1, installed with pip)

@jack-mcivor
Copy link
Author

Had a quick look around & I guess this is just the default behaviour of argparse.ArgumentParser. Not sure if there is an easy fix here without changing this line https://github.com/quora/pyanalyze/blob/f2cc7074a7f9b59fa471f2a2301fa7570957df03/pyanalyze/node_visitor.py#L922C30-L922C30 to not enumerate codes.

@JelleZijlstra
Copy link
Contributor

I agree this looks a bit excessive. Maybe we can use type= (https://docs.python.org/3.10/library/argparse.html#type) instead of choices to validate the arguments, and add to the help text something pointing to docs about the available error codes. For example, error_code.py (where the error codes are defined) could be added to https://pyanalyze.readthedocs.io/en/latest/py-modindex.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants