# HG changeset patch # User Cameron Simpson # Date 1718956406 -36000 # Fri Jun 21 17:53:26 2024 +1000 # Node ID 3fe6ebd0d29540930409f286e63b7d87412084bd # Parent a7fbd30531c51190326658060abbb89c8aa10696 replace many raises of RuntimeError with NotImplementedError, suggestion by @dimaqq on disucss.python.org diff --git a/lib/python/cs/app/cloudbackup.py b/lib/python/cs/app/cloudbackup.py --- a/lib/python/cs/app/cloudbackup.py +++ b/lib/python/cs/app/cloudbackup.py @@ -165,7 +165,7 @@ elif opt == '-k': options.key_name = val else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") try: options.cloud_area except ValueError as e: @@ -196,7 +196,7 @@ if opt == '-R': use_realpath = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if not argv: warning("missing backup_root") badopts = True @@ -340,7 +340,7 @@ elif opt == '-l': long_mode = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") cloud_backup = options.cloud_backup if not argv: for backup_name in cloud_backup.keys(): @@ -469,7 +469,7 @@ elif opt == '-U': backup_uuid = val else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if restore_dirpath is None: warning("missing mandatory -o outputdir option") badopts = True diff --git a/lib/python/cs/app/dlog.py b/lib/python/cs/app/dlog.py --- a/lib/python/cs/app/dlog.py +++ b/lib/python/cs/app/dlog.py @@ -412,7 +412,7 @@ raise GetoptError("unparsed date: %s" % (e,)) options.when = datetime2unixtime(dt) else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") if dt is None: dt = datetime.fromtimestamp(options.when) if badopts: diff --git a/lib/python/cs/app/mailfiler.py b/lib/python/cs/app/mailfiler.py --- a/lib/python/cs/app/mailfiler.py +++ b/lib/python/cs/app/mailfiler.py @@ -164,7 +164,7 @@ if opt == '-R': self.options.rules_pattern = val else: - raise RuntimeError("unhandled option: %s %r" % (opt, val)) + raise NotImplementedError("unhandled option: %s %r" % (opt, val)) def cmd_monitor(self, argv): ''' Usage: {cmd} [-1] [-d delay] [-n] [maildirs...] diff --git a/lib/python/cs/app/mklinks.py b/lib/python/cs/app/mklinks.py --- a/lib/python/cs/app/mklinks.py +++ b/lib/python/cs/app/mklinks.py @@ -85,7 +85,7 @@ if opt == '-n': self.options.dry_run = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") @uses_runstate def main(self, argv, *, runstate: RunState): diff --git a/lib/python/cs/app/myke/__main__.py b/lib/python/cs/app/myke/__main__.py --- a/lib/python/cs/app/myke/__main__.py +++ b/lib/python/cs/app/myke/__main__.py @@ -64,7 +64,7 @@ elif opt == '-n': M.no_action = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") def apply_preargv(self, argv): # gather any macro assignments and apply diff --git a/lib/python/cs/app/pilfer.py b/lib/python/cs/app/pilfer.py --- a/lib/python/cs/app/pilfer.py +++ b/lib/python/cs/app/pilfer.py @@ -1363,7 +1363,7 @@ elif name == 'pipe': return ActionPipeTo(action0, pipe_name) else: - raise RuntimeError("unhandled action %r" % (name,)) + raise NotImplementedError("unhandled action %r" % (name,)) if name == 'grok' or name == 'grokall': # grok:a.b.c.d[:args...] @@ -1446,7 +1446,7 @@ return FUNC_ONE_TO_MANY, grokall else: - raise RuntimeError("unhandled action %r", name) + raise NotImplementedError("unhandled action %r", name) if name == 'for': # for:varname=value,... @@ -1535,7 +1535,7 @@ return not any([P.seen(see_value, seenset) for seenset in seensets]) return FUNC_SELECTOR, unseen - raise RuntimeError("unsupported action %r", name) + raise NotImplementedError("unsupported action %r", name) if name == 'unique': # unique diff --git a/lib/python/cs/app/playon.py b/lib/python/cs/app/playon.py --- a/lib/python/cs/app/playon.py +++ b/lib/python/cs/app/playon.py @@ -300,7 +300,7 @@ elif opt == '-n': no_download = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if not argv: argv = ['pending'] api = options.api @@ -404,7 +404,7 @@ elif opt == '-o': listing_format = val else: - raise RuntimeError("unhandled option: %r" % (opt,)) + raise NotImplementedError("unhandled option: %r" % (opt,)) if not argv: argv = list(default_argv) xit = 0 diff --git a/lib/python/cs/app/portfwd.py b/lib/python/cs/app/portfwd.py --- a/lib/python/cs/app/portfwd.py +++ b/lib/python/cs/app/portfwd.py @@ -196,7 +196,7 @@ elif opt == '-v': verbose = True else: - raise RuntimeError('unhandled option') + raise NotImplementedError('unsupported option') if not argv and not auto_mode: raise GetoptError( "missing targets; targets or -A (auto) option required" diff --git a/lib/python/cs/app/svcd.py b/lib/python/cs/app/svcd.py --- a/lib/python/cs/app/svcd.py +++ b/lib/python/cs/app/svcd.py @@ -254,7 +254,7 @@ elif opt == '-x': trace = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if not argv: warning("missing command") if name is None: diff --git a/lib/python/cs/app/tagger/__init__.py b/lib/python/cs/app/tagger/__init__.py --- a/lib/python/cs/app/tagger/__init__.py +++ b/lib/python/cs/app/tagger/__init__.py @@ -647,7 +647,7 @@ for tag in inferred_tags.as_tags(): tagged.add(tag) else: - raise RuntimeError("unhandled mode %r" % (mode,)) + raise NotImplementedError("unhandled mode %r" % (mode,)) return inferred_tags uses_tagger = default_params(tagger=Tagger.default) diff --git a/lib/python/cs/app/tagger/__main__.py b/lib/python/cs/app/tagger/__main__.py --- a/lib/python/cs/app/tagger/__main__.py +++ b/lib/python/cs/app/tagger/__main__.py @@ -85,7 +85,7 @@ elif opt == '-v': options.verbose = True else: - raise RuntimeError(f'unhandled option: {opt!r}') + raise NotImplementedError(f'unsupported option: {opt!r}') @contextmanager @uses_fstags @@ -242,7 +242,7 @@ elif opt == '-n': infill_mode = 'infer' else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if not argv: raise GetoptError("missing paths") for path in argv: diff --git a/lib/python/cs/app/tagger/rules.py b/lib/python/cs/app/tagger/rules.py --- a/lib/python/cs/app/tagger/rules.py +++ b/lib/python/cs/app/tagger/rules.py @@ -403,7 +403,7 @@ case TagChange() as tag_change: result.tag_changes.append(tag_change) case _: - raise RuntimeError(f'unhandled side effect {r(side_effect)}') + raise NotImplementedError(f'unsupported side effect {r(side_effect)}') return result @typechecked diff --git a/lib/python/cs/app/ydl.py b/lib/python/cs/app/ydl.py --- a/lib/python/cs/app/ydl.py +++ b/lib/python/cs/app/ydl.py @@ -139,7 +139,7 @@ if options.parallel < 1: raise GetoptError("must be >= 1") else: - raise RuntimeError("unhandled option: %s=%s" % (opt, val)) + raise NotImplementedError("unhandled option: %s=%s" % (opt, val)) def main(self, argv): ''' Command line main programme. diff --git a/lib/python/cs/cdrip.py b/lib/python/cs/cdrip.py --- a/lib/python/cs/cdrip.py +++ b/lib/python/cs/cdrip.py @@ -286,7 +286,7 @@ elif opt == '-R': do_refresh = True else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") if not argv: if mbdb.dev_info: argv = ['disc.' + mbdb.dev_info.id] diff --git a/lib/python/cs/cloud/__main__.py b/lib/python/cs/cloud/__main__.py --- a/lib/python/cs/cloud/__main__.py +++ b/lib/python/cs/cloud/__main__.py @@ -61,7 +61,7 @@ if opt == '-A': self.options.cloud_area_path = val else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") def cmd_stat(self, argv): ''' Usage: {cmd} diff --git a/lib/python/cs/cmdutils.py b/lib/python/cs/cmdutils.py --- a/lib/python/cs/cmdutils.py +++ b/lib/python/cs/cmdutils.py @@ -879,7 +879,7 @@ and would imply that a `GETOPT_SPEC` was supplied without an `apply_opt` or `apply_opts` method to implement the options. ''' - raise RuntimeError("unhandled option %r" % (opt,)) + raise NotImplementedError("unhandled option %r" % (opt,)) def apply_opts(self, opts): ''' Apply command line options. diff --git a/lib/python/cs/distinfo.py b/lib/python/cs/distinfo.py --- a/lib/python/cs/distinfo.py +++ b/lib/python/cs/distinfo.py @@ -169,7 +169,7 @@ elif opt == '-v': options.verbose = True else: - raise RuntimeError("unhandled option: %s" % (opt,)) + raise NotImplementedError("unhandled option: %s" % (opt,)) @contextmanager def run_context(self): diff --git a/lib/python/cs/ebooks/dedrm.py b/lib/python/cs/ebooks/dedrm.py --- a/lib/python/cs/ebooks/dedrm.py +++ b/lib/python/cs/ebooks/dedrm.py @@ -75,7 +75,7 @@ if opt == '-D': self.options.dedrm_package_path = val else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if badopt: raise GetoptError("bad option value") diff --git a/lib/python/cs/fstags.py b/lib/python/cs/fstags.py --- a/lib/python/cs/fstags.py +++ b/lib/python/cs/fstags.py @@ -219,7 +219,7 @@ elif opt == '-P': options.physical = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") @contextmanager def run_context(self): @@ -319,7 +319,7 @@ elif opt == '-d': directories_like_files = True else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if not argv: path = '.' else: @@ -362,7 +362,7 @@ elif opt == '--direct': use_direct_tags = True else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") if not argv: warning("missing path") badopts = True @@ -419,7 +419,7 @@ elif opt == '-o': output_format = fstags.resolve_format_string(value) else: - raise RuntimeError("unsupported option") + raise NotImplementedError("unsupported option") if not argv: warning("missing path") badopts = True @@ -537,7 +537,7 @@ if opt == '--prefix': tag_prefix = value else: - raise RuntimeError("unimplemented option") + raise NotImplementedError("unimplemented option") if tag_prefix is None: warning("missing required --prefix option") badopts = True @@ -696,7 +696,7 @@ elif subopt == '-v': cmd_verbose = True else: - raise RuntimeError("unhandled subopt: %r" % (subopt,)) + raise NotImplementedError("unhandled subopt: %r" % (subopt,)) if len(argv) < 2: raise GetoptError("missing paths or targetdir") endpath = argv[-1] @@ -752,7 +752,7 @@ elif opt == '--direct': use_direct_tags = True else: - raise RuntimeError("unsupported option") + raise NotImplementedError("unsupported option") xit = 0 paths = argv or ['.'] for path in paths: @@ -804,7 +804,7 @@ if subopt == '-o': name_format = fstags.resolve_format_string(value) else: - raise RuntimeError("unhandled subopt: %r" % (subopt,)) + raise NotImplementedError("unhandled subopt: %r" % (subopt,)) if name_format is None: raise GetoptError("missing -o option") if not argv: @@ -995,7 +995,7 @@ if opt == '--direct': use_direct_tags = True else: - raise RuntimeError("unsupported option") + raise NotImplementedError("unsupported option") if not argv: warning("missing path") badopts = True diff --git a/lib/python/cs/iso14496.py b/lib/python/cs/iso14496.py --- a/lib/python/cs/iso14496.py +++ b/lib/python/cs/iso14496.py @@ -282,7 +282,7 @@ if option in ('-p', '--prefix'): tag_prefix = value else: - raise RuntimeError("unsupported option") + raise NotImplementedError("unsupported option") if not argv: raise GetoptError("missing path") path = argv.pop(0) @@ -1542,7 +1542,7 @@ self.parse_field('timescale', bfr, UInt32BE) self.parse_field('duration', bfr, UInt64BE) else: - raise RuntimeError("unsupported version %d" % (self.version,)) + raise NotImplementedError("unsupported version %d" % (self.version,)) self.parse_field('language_short', bfr, UInt16BE) self.parse_field('pre_defined', bfr, UInt16BE) diff --git a/lib/python/cs/m3/material.py b/lib/python/cs/m3/material.py --- a/lib/python/cs/m3/material.py +++ b/lib/python/cs/m3/material.py @@ -385,7 +385,7 @@ elif slice_dim == 2: abc_fn = lambda a, b, c: (a, b, c) else: - raise RuntimeError("unhandled slice_dim %s" % (r(slice_dim),)) + raise NotImplementedError("unhandled slice_dim %s" % (r(slice_dim),)) c = slice_index surface = Surface(f'surface_{alabel}_{blabel}_{clabel}{c}') # enumerate all the polygons diff --git a/lib/python/cs/splink.py b/lib/python/cs/splink.py --- a/lib/python/cs/splink.py +++ b/lib/python/cs/splink.py @@ -722,7 +722,7 @@ elif opt == '-n': options.doit = False else: - raise RuntimeError("unhandled pre-option") + raise NotImplementedError("unhandled pre-option") def print_known_datasets(self, file=None): ''' Print the known datasets and their fields to `file`. diff --git a/lib/python/cs/sqltags.py b/lib/python/cs/sqltags.py --- a/lib/python/cs/sqltags.py +++ b/lib/python/cs/sqltags.py @@ -667,7 +667,7 @@ ) constraint = constraint_fn and constraint_fn(alias, timestamp) else: - raise RuntimeError("unhandled non-tag field %r" % (tag_name,)) + raise NotImplementedError("unhandled non-tag field %r" % (tag_name,)) sqlp = SQLParameters( criterion=self, alias=alias, @@ -2080,7 +2080,7 @@ ) ) else: - raise RuntimeError("unimplemented export format %r" % (export_format,)) + raise NotImplementedError("unimplemented export format %r" % (export_format,)) # pylint: disable=too-many-locals def cmd_find(self, argv): @@ -2148,7 +2148,7 @@ if option in ('-u', '--update'): update_mode = True else: - raise RuntimeError("unsupported option") + raise NotImplementedError("unsupported option") if not argv: warning("missing srcpaths") badopts = True @@ -2210,7 +2210,7 @@ elif opt == '-D': strptime_format = val else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") if dt is not None and strptime_format is not None: warning("-d and -D are mutually exclusive") badopts = True diff --git a/lib/python/cs/timeseries.py b/lib/python/cs/timeseries.py --- a/lib/python/cs/timeseries.py +++ b/lib/python/cs/timeseries.py @@ -469,7 +469,7 @@ ) # pylint: too-many-function-args.disable=missing-kwoa figure = (ax[0] if options.multi else ax).figure else: - raise RuntimeError("unhandled type %s" % (s(ts),)) + raise NotImplementedError("unhandled type %s" % (s(ts),)) if runstate.cancelled: return 1 if bare: @@ -520,7 +520,7 @@ raise GetoptError("ts-step must be >0, got %s" % (ts_step,)) self.options.ts_step = ts_step else: - raise RuntimeError("unhandled option") + raise NotImplementedError("unhandled option") def apply_preargv(self, argv): ''' Parse a leading time series filesystem path from `argv`, diff --git a/lib/python/cs/vt/__main__.py b/lib/python/cs/vt/__main__.py --- a/lib/python/cs/vt/__main__.py +++ b/lib/python/cs/vt/__main__.py @@ -324,7 +324,7 @@ # verbose: not quiet options.verbose = True else: - raise RuntimeError("unhandled option: %s" % (opt,)) + raise NotImplementedError("unhandled option: %s" % (opt,)) if options.verbose: self.loginfo.level = logging.INFO if options.dflt_log is not None: @@ -849,7 +849,7 @@ elif opt == '-r': readonly = True else: - raise RuntimeError("unhandled option: %r" % (opt,)) + raise NotImplementedError("unhandled option: %r" % (opt,)) # special is either a D{dir} or [clause] or an archive pathname mount_store = Store.default() special_basename = None