-
Notifications
You must be signed in to change notification settings - Fork 77
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
better error when missing CTE #257
Comments
sample notebook: sample.ipynb.zip |
I can look into it! |
regarding this: "To provide a more helpful message, we can also use difflib to check if there are any closes matches:" The function difflib.get_close_matches(word, possibilities, n=3, cutoff=0.6) takes parameter possibilities as a list of sequences against which to match word, since key can be user defined example |
I think I will return the best match if it exist or else return the entire keys: if key not in self._data:
matches = difflib.get_close_matches(key, self._data)
if matches:
raise UsageError(f"{key!r} is not a valid snippet identifier. Did you mean {matches[0]!r}?")
else:
valid = ", ".join(f'"{key}"' for key in self._data.keys())
raise UsageError(f"{key!r} is not a valid snippet identifier. Valid identifiers are {valid}.") is this is a sound approach? |
when using the
--with
argument, this runs; however, if the passed key does not exist, the error traceback is pretty long (see attached notebook).Instead, we should raise an UsageError:
To provide a more helpful message, we can also use difflib to check if there are any closes matches:
If there are no close matches, we can display all available keys:
The text was updated successfully, but these errors were encountered: