diff --git a/docs/make_readme.py b/docs/make_readme.py index 18575d6..b42e235 100644 --- a/docs/make_readme.py +++ b/docs/make_readme.py @@ -33,16 +33,16 @@ def write_examples(maker: ReadmeMaker) -> None: maker.write_chapter("Check a filename") maker.write_file(example_root.joinpath("is_valid_filename_code.txt")) - maker.write_chapter("filename/filepath validator for argparse") + maker.write_chapter("filename/filepath validator for ``argparse``") maker.write_file(example_root.joinpath("argparse_validator.txt")) - maker.write_chapter("filename/filepath sanitizer for argparse") + maker.write_chapter("filename/filepath sanitizer for ``argparse``") maker.write_file(example_root.joinpath("argparse_sanitizer.txt")) - maker.write_chapter("filename/filepath validator for click") + maker.write_chapter("filename/filepath validator for ``click``") maker.write_file(example_root.joinpath("click_validator.txt")) - maker.write_chapter("filename/filepath sanitizer for click") + maker.write_chapter("filename/filepath sanitizer for ``click``") maker.write_file(example_root.joinpath("click_sanitizer.txt")) maker.write_chapter("For more information") diff --git a/docs/pages/examples/argparse_validator.txt b/docs/pages/examples/argparse_validator.txt index 779d0c0..45e5a66 100644 --- a/docs/pages/examples/argparse_validator.txt +++ b/docs/pages/examples/argparse_validator.txt @@ -6,24 +6,24 @@ from pathvalidate.argparse import validate_filename_arg, validate_filepath_arg parser = ArgumentParser() - parser.add_argument("--filepath", type=validate_filepath_arg) parser.add_argument("--filename", type=validate_filename_arg) + parser.add_argument("--filepath", type=validate_filepath_arg) options = parser.parse_args() if options.filename: - print("filename: {}".format(options.filename)) + print(f"filename: {options.filename}") if options.filepath: - print("filepath: {}".format(options.filepath)) + print(f"filepath: {options.filepath}") :Output: .. code-block:: none $ ./examples/argparse_validate.py --filename eg filename: eg - $ ./examples/argparse_validate.py --filepath e?g - usage: argparse_validate.py [-h] [--filepath FILEPATH] [--filename FILENAME] - argparse_validate.py: error: argument --filepath: invalid char found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER, target-platform=Windows + $ ./examples/argparse_validate.py --filename e?g + usage: argparse_validate.py [-h] [--filename FILENAME] [--filepath FILEPATH] + argparse_validate.py: error: argument --filename: [PV1100] invalid characters found: invalids=(':'), value='e:g', target-platform=Windows .. note:: ``validate_filepath_arg`` consider ``platform`` as of ``"auto"`` if the input is an absolute file path. diff --git a/docs/pages/examples/click.rst b/docs/pages/examples/click.rst index 72820dc..e693c3f 100644 --- a/docs/pages/examples/click.rst +++ b/docs/pages/examples/click.rst @@ -1,8 +1,8 @@ -filename/filepath validator for click +filename/filepath validator for ``click`` -------------------------------------------------------- .. include:: click_validator.txt -filename/filepath sanitizer for click +filename/filepath sanitizer for ``click`` -------------------------------------------------------- .. include:: click_sanitizer.txt diff --git a/docs/pages/examples/click_sanitizer.txt b/docs/pages/examples/click_sanitizer.txt index 2edf680..bc3e452 100644 --- a/docs/pages/examples/click_sanitizer.txt +++ b/docs/pages/examples/click_sanitizer.txt @@ -11,9 +11,9 @@ @click.option("--filepath", callback=sanitize_filepath_arg) def cli(filename, filepath): if filename: - click.echo("filename: {}".format(filename)) + click.echo(f"filename: {filename}") if filepath: - click.echo("filepath: {}".format(filepath)) + click.echo(f"filepath: {filepath}") if __name__ == "__main__": diff --git a/docs/pages/examples/click_validator.txt b/docs/pages/examples/click_validator.txt index aaa0c16..db61cc6 100644 --- a/docs/pages/examples/click_validator.txt +++ b/docs/pages/examples/click_validator.txt @@ -9,11 +9,11 @@ @click.command() @click.option("--filename", callback=validate_filename_arg) @click.option("--filepath", callback=validate_filepath_arg) - def cli(filename, filepath): + def cli(filename: str, filepath: str) -> None: if filename: - click.echo("filename: {}".format(filename)) + click.echo(f"filename: {filename}") if filepath: - click.echo("filepath: {}".format(filepath)) + click.echo(f"filepath: {filepath}") if __name__ == "__main__": @@ -26,5 +26,6 @@ filename: ab $ ./examples/click_validate.py --filepath e?g Usage: click_validate.py [OPTIONS] + Try 'click_validate.py --help' for help. - Error: Invalid value for "--filepath": invalid char found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER, target-platform=Windows + Error: Invalid value for '--filename': [PV1100] invalid characters found: invalids=('?'), value='e?g', target-platform=Windows diff --git a/docs/pages/examples/validate_filename_code.txt b/docs/pages/examples/validate_filename_code.txt index 028db16..396ca8b 100644 --- a/docs/pages/examples/validate_filename_code.txt +++ b/docs/pages/examples/validate_filename_code.txt @@ -17,6 +17,6 @@ :Output: .. code-block:: none - invalid char found: invalids=(':', '*', '/', '"', '?', '>', '|', '<'), value='fi:l*e/p"a?t>h|.t', '|', '<'), value='fi:l*e/p"a?t>h|.t', '|', '<'), value='fi:l*e/p"a?t>h|.t