Skip to content

Commit

Permalink
treewide: Disable automatic argparse argument shortening
Browse files Browse the repository at this point in the history
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <[email protected]>
  • Loading branch information
nordicjm authored and stephanosio committed Jan 26, 2023
1 parent d428c8c commit ec70444
Show file tree
Hide file tree
Showing 85 changed files with 104 additions and 97 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ execute_process(
${ZEPHYR_BASE}/scripts/build/subfolder_list.py
--directory ${ZEPHYR_BASE}/include # Walk this directory
--out-file ${syscalls_subdirs_txt} # Write file with discovered folder
--trigger ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
--trigger-file ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
${syscalls_links} # If defined, create symlinks for dependencies
)
file(STRINGS ${syscalls_subdirs_txt} PARSE_SYSCALLS_PATHS_DEPENDS ENCODING UTF-8)
Expand Down Expand Up @@ -644,7 +644,7 @@ else()
${ZEPHYR_BASE}/scripts/build/subfolder_list.py
--directory ${ZEPHYR_BASE}/include # Walk this directory
--out-file ${syscalls_subdirs_txt} # Write file with discovered folder
--trigger ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
--trigger-file ${syscalls_subdirs_trigger} # Trigger file that is used for json generation
${syscalls_links} # If defined, create symlinks for dependencies
DEPENDS ${PARSE_SYSCALLS_PATHS_DEPENDS}
)
Expand Down Expand Up @@ -740,7 +740,7 @@ add_custom_command(OUTPUT include/generated/syscall_dispatch.c ${syscall_list_h}
)

# This is passed into all calls to the gen_kobject_list.py script.
set(gen_kobject_list_include_args --include ${struct_tags_json})
set(gen_kobject_list_include_args --include-subsystem-list ${struct_tags_json})

set(DRV_VALIDATION ${PROJECT_BINARY_DIR}/include/generated/driver-validation.h)
add_custom_command(
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/gen_gdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-k", "--kernel", required=True,
help="Zephyr kernel image")
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/gen_idt.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-m", "--vector-map", required=True,
help="Output file mapping IRQ lines to IDT vectors")
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/gen_mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-k", "--kernel", required=True,
help="path to prebuilt kernel ELF binary")
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/zefi/zefi.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def build_elf(elf_file, include_dirs):
def parse_args():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-c", "--compiler", required=True, help="Compiler to be used")
parser.add_argument("-o", "--objcopy", required=True, help="objcopy to be used")
Expand Down
2 changes: 1 addition & 1 deletion doc/_scripts/gen_devicetree_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def main():
def parse_args():
# Parse command line arguments from sys.argv.

parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument('-v', '--verbose', default=0, action='count',
help='increase verbosity; may be given multiple times')
parser.add_argument('--vendor-prefixes', required=True,
Expand Down
2 changes: 1 addition & 1 deletion samples/modules/tflite-micro/magic_wand/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def train_net(


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--model", "-m")
parser.add_argument("--person", "-p")
args = parser.parse_args()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def parse_args():
global args

parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument(
"-d", "--device", required=True,
Expand Down
2 changes: 1 addition & 1 deletion samples/subsys/zbus/remote_mock/remote_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]"""

channels = json.loads(j)
parser = argparse.ArgumentParser(description='Read zbus events via serial.')
parser = argparse.ArgumentParser(description='Read zbus events via serial.', allow_abbrev=False)
parser.add_argument("port", type=str, help='The tty or COM port to be used')

args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion samples/subsys/zbus/uart_bridge/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]
"""

parser = argparse.ArgumentParser(description='Read zbus events via serial.')
parser = argparse.ArgumentParser(description='Read zbus events via serial.', allow_abbrev=False)
parser.add_argument("port", type=str, help='The tty or COM port to be used')

args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion samples/tfm_integration/psa_firmware/split-header.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def dump_header(infile, image, header):
inhex.tobinfile(header, start=start, end=end-1)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument('input')
parser.add_argument('image')
parser.add_argument('header')
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/file2hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-f", "--file", required=True, help="Input file")
parser.add_argument("-g", "--gzip", action="store_true",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_app_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)
parser.add_argument("-d", "--directory", required=False, default=None,
help="Root build directory")
parser.add_argument("-e", "--elf", required=False, default=None,
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_cfb_font_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description="Character Frame Buffer (CFB) font header file generator",
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument(
"-z", "--zephyr-base",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-k", "--kernel", required=True,
help="Input zephyr ELF binary")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def main():
parser = argparse.ArgumentParser(description='''
Process ELF file and extract image information.
Create header file with extracted image information which can be included
in other build systems.''')
in other build systems.''', allow_abbrev=False)

parser.add_argument('--header-file', required=True,
help="""Header file to write with image data.""")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_isr_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def parse_args():
global args

parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-e", "--big-endian", action="store_true",
help="Target encodes data in big-endian format (little endian is "
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-k", "--kernel", required=False,
help="Input zephyr ELF binary")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_kobject_placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("--object", required=True,
help="Points to kobject_prebuilt_hash.c.obj")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_offset_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def gen_offset_header(input_name, input_file, output_file):
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument(
"-i",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_relocate_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)
parser.add_argument("-d", "--directory", required=True,
help="obj file's directory")
parser.add_argument("-i", "--input_rel_dict", required=True,
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_strerror_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def gen_strerror_table(input, output):


def parse_args():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument(
'-i',
'--input',
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-i", "--json-file", required=True,
help="Read syscall information from json file")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/mergehex.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def merge_hex_files(output, input_hex_files, overlap):
def parse_args():
parser = argparse.ArgumentParser(
description="Merge hex files.",
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)
parser.add_argument("-o", "--output", required=False, default="merged.hex",
type=argparse.FileType('w', encoding='UTF-8'),
help="Output file name.")
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/parse_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def parse_args():
global args
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument("-i", "--include", required=True, action='append',
help='''include directories recursively scanned
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/process_gperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def parse_args():

parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter,
allow_abbrev=False)

parser.add_argument("-i", "--input", required=True,
help="Input C file from gperf")
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/subfolder_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def parse_args():
"""Parse command line arguments and options"""
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter,
allow_abbrev=False)

parser.add_argument('-d', '--directory', required=True,
help='Directory to walk for sub-directory discovery')
Expand Down
3 changes: 2 additions & 1 deletion scripts/build/uf2conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def main():
def error(msg):
print(msg)
sys.exit(1)
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.',
allow_abbrev=False)
parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
help='input file (HEX, BIN or UF2)')
parser.add_argument('-b' , '--base', dest='base', type=str,
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def get_kconfig_dts(self, kconfig_dts_file):
"gen_driver_kconfig_dts.py")
binding_path = os.path.join(ZEPHYR_BASE, "dts", "bindings")
cmd = [sys.executable, zephyr_drv_kconfig_path,
'--kconfig-out', kconfig_dts_file, '--bindings', binding_path]
'--kconfig-out', kconfig_dts_file, '--bindings-dirs', binding_path]
try:
subprocess.run(cmd, check=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def parse_args():

default_range = 'HEAD~1..HEAD'
parser = argparse.ArgumentParser(
description="Check for coding style and documentation warnings.")
description="Check for coding style and documentation warnings.", allow_abbrev=False)
parser.add_argument('-c', '--commits', default=default_range,
help=f'''Commit range in the form: a..[b], default is
{default_range}''')
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/guideline_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def parse_coccinelle(contents: str, violations: dict):

def parse_args():
parser = argparse.ArgumentParser(
description="Check if change requires full twister")
description="Check if change requires full twister", allow_abbrev=False)
parser.add_argument('-c', '--commits', default=None,
help="Commit range in the form: a..b")
parser.add_argument("-o", "--output", required=False,
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def find_excludes(self, skip=[]):

def parse_args():
parser = argparse.ArgumentParser(
description="Generate twister argument files based on modified file")
description="Generate twister argument files based on modified file",
allow_abbrev=False)
parser.add_argument('-c', '--commits', default=None,
help="Commit range in the form: a..b")
parser.add_argument('-m', '--modified-files', default=None,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/upload_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main():


def parse_args():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument('-u', '--user', help='username')
parser.add_argument('-p', '--password', help='password')
parser.add_argument('-i', '--index', help='index to push to.', required=True)
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/version_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def parse_args():
parser = argparse.ArgumentParser(
description="Manage versions to be tested.")
description="Manage versions to be tested.", allow_abbrev=False)
parser.add_argument('-l', '--list', action="store_true",
help="List all published versions")
parser.add_argument('-u', '--update',
Expand Down
2 changes: 1 addition & 1 deletion scripts/coredump/coredump_gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def parse_args():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)

parser.add_argument("elffile", help="Zephyr ELF binary")
parser.add_argument("logfile", help="Coredump binary log file")
Expand Down
2 changes: 1 addition & 1 deletion scripts/coredump/coredump_serial_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def parse_args():
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)

parser.add_argument("infile", help="Serial Log File")
parser.add_argument("outfile",
Expand Down
2 changes: 1 addition & 1 deletion scripts/dts/gen_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def node_z_path_id(node):
def parse_args():
# Returns parsed command-line arguments

parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--dts", required=True, help="DTS file")
parser.add_argument("--dtc-flags",
help="'dtc' devicetree compiler flags, some of which "
Expand Down
2 changes: 1 addition & 1 deletion scripts/dts/gen_driver_kconfig_dts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def binding_paths(bindings_dirs):
def parse_args():
# Returns parsed command-line arguments

parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--kconfig-out", required=True,
help="path to write the Kconfig file")
parser.add_argument("--bindings-dirs", nargs='+', required=True,
Expand Down
2 changes: 1 addition & 1 deletion scripts/dts/gen_dts_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def parse_args():
# Returns parsed command-line arguments

parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--cmake-out", required=True,
help="path to write the CMake property file")
parser.add_argument("--edt-pickle", required=True,
Expand Down
2 changes: 1 addition & 1 deletion scripts/dump_bugs_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)

parser.add_argument('pickle_file', metavar='PICKLE-FILE', type=Path,
help='pickle file containing list of issues')
Expand Down
3 changes: 2 additions & 1 deletion scripts/footprint/compare_footprint
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def init_logs():
def parse_args():
parser = argparse.ArgumentParser(
description="Compare footprint apps RAM and ROM sizes. Note: "
"To run it you need to set up the same environment as twister.")
"To run it you need to set up the same environment as twister.",
allow_abbrev=False)
parser.add_argument('-b', '--base-commit', default=None,
help="Commit ID to use as base for footprint "
"compare. Default is parent current commit."
Expand Down
Loading

0 comments on commit ec70444

Please sign in to comment.