diff --git a/.docs/README_template.rst b/.docs/README_template.rst index 074e900..934290c 100644 --- a/.docs/README_template.rst +++ b/.docs/README_template.rst @@ -2,7 +2,7 @@ rst_include =========== -Version v2.1.0 as of 2020-08-08 see `Changelog`_ +Version v2.1.1 as of 2020-10-09 see `Changelog`_ .. include:: ./badges.rst diff --git a/.docs/badges.rst b/.docs/badges.rst index 79c24c4..5007ae9 100644 --- a/.docs/badges.rst +++ b/.docs/badges.rst @@ -1,4 +1,4 @@ -|travis_build| |license| |pypi| +|travis_build| |license| |pypi| |codecov| |better_code| |cc_maintain| |cc_issues| |cc_coverage| |snyk| @@ -36,3 +36,6 @@ .. |snyk| image:: https://img.shields.io/snyk/vulnerabilities/github/bitranox/rst_include :target: https://snyk.io/test/github/bitranox/rst_include + +.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black diff --git a/.docs/tested_under.rst b/.docs/tested_under.rst index ac4ee73..c5c1a58 100644 --- a/.docs/tested_under.rst +++ b/.docs/tested_under.rst @@ -1,3 +1,3 @@ -tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 +tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.9-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 `100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring diff --git a/.travis.yml b/.travis.yml index f7ebe3f..b0f21ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,7 @@ matrix: - os: windows if: true language: sh - name: "Windows Python 3.8" + name: "Windows Python 3.9" # oddly a secure password under env: global: causes that choco fails # so we need to put the option : filter_secrets: false @@ -71,7 +71,7 @@ matrix: - chmod -R 0755 /usr/local/lib_bash - chmod -R +x /usr/local/lib_bash/*.sh - /usr/local/lib_bash/lib_retry.sh retry choco install python3 - - export PATH="/c/Python38:/c/Python38/Scripts:$PATH" + - export PATH="/c/Python310:/c/Python310/Scripts:/c/Python39:/c/Python39/Scripts:/c/Python38:/c/Python38/Scripts:$PATH" - export BUILD_DOCS="False" - export DEPLOY_SDIST="False" - export DEPLOY_WHEEL="False" @@ -119,7 +119,7 @@ matrix: arch: "amd64" if: true language: python - python: "3.8-dev" + python: "3.9-dev" before_install: - export BUILD_DOCS="False" - export DEPLOY_SDIST="True" diff --git a/CHANGES.rst b/CHANGES.rst index 830f3fd..fd210b0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,12 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v2.1.1 +-------- +2020-10-09: service release + - update travis build matrix for linux 3.9-dev + - update travis build matrix (paths) for windows 3.9 / 3.10 + v2.1.0 -------- 2020-08-08: service release diff --git a/README.rst b/README.rst index 2578da8..928e9e3 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ rst_include =========== -Version v2.1.0 as of 2020-08-08 see `Changelog`_ +Version v2.1.1 as of 2020-10-09 see `Changelog`_ |travis_build| |license| |pypi| @@ -43,6 +43,9 @@ Version v2.1.0 as of 2020-08-08 see `Changelog`_ .. |snyk| image:: https://img.shields.io/snyk/vulnerabilities/github/bitranox/rst_include :target: https://snyk.io/test/github/bitranox/rst_include +.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + since You can not include files into RST files on github or PyPi, You can resolve such imports with this software. That means You can locally write Your RST documents (for instance with pycharm) and use there @@ -67,7 +70,7 @@ automated tests, Travis Matrix, Documentation, Badges, etc. are managed with `Pi Python version required: 3.6.0 or newer -tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 +tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.9-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64 `100% code coverage `_, flake8 style checking ,mypy static type checking ,tested under `Linux, macOS, Windows `_, automatic daily builds and monitoring @@ -474,6 +477,12 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes +v2.1.1 +-------- +2020-10-09: service release + - update travis build matrix for linux 3.9-dev + - update travis build matrix (paths) for windows 3.9 / 3.10 + v2.1.0 -------- 2020-08-08: service release diff --git a/rst_include/__init__conf__.py b/rst_include/__init__conf__.py index 6ac28db..155ffc8 100644 --- a/rst_include/__init__conf__.py +++ b/rst_include/__init__conf__.py @@ -1,6 +1,6 @@ name = 'rst_include' title = 'commandline tool to resolve RST File includes' -version = 'v2.1.0' +version = 'v2.1.1' url = 'https://github.com/bitranox/rst_include' author = 'Robert Nowotny' author_email = 'bitranox@gmail.com' @@ -14,7 +14,7 @@ def print_info() -> None: commandline tool to resolve RST File includes - Version : v2.1.0 + Version : v2.1.1 Url : https://github.com/bitranox/rst_include Author : Robert Nowotny Email : bitranox@gmail.com""") diff --git a/rst_include/libs/lib_assemble_block.py b/rst_include/libs/lib_assemble_block.py index af4c4fe..bc8a4b1 100644 --- a/rst_include/libs/lib_assemble_block.py +++ b/rst_include/libs/lib_assemble_block.py @@ -156,7 +156,7 @@ def get_block_header(block: Block) -> str: content = '' if block.include_file_code: content_lines = list() - content_lines.append('.. code-block:: {code}'.format(code=block.include_file_code)) + content_lines.append(f'.. code-block:: {block.include_file_code}') content_lines = content_lines + [pass_through_option.content for pass_through_option in block.pass_through_options] content = '\n'.join(content_lines) return content diff --git a/rst_include/libs/lib_block_options.py b/rst_include/libs/lib_block_options.py index 97a58c3..d05ae79 100644 --- a/rst_include/libs/lib_block_options.py +++ b/rst_include/libs/lib_block_options.py @@ -147,10 +147,7 @@ def get_option_key_from_source_line(source_line: SourceLine) -> str: def log_and_raise_value_error_if_option_not_in_block(option: str, block: Block) -> None: if not is_option_in_block(option, block): - s_error = 'Error in File: "{file}", option "{option}" not found in block starting with Line: {line}'.format( - file=block.source, - option=option, - line=block.l_source_lines[0].line_number) + s_error = f'Error in File: "{block.source}", option "{option}" not found in block starting with Line: {block.l_source_lines[0].line_number}' lib_log_utils.log_error(s_error) raise ValueError(s_error) @@ -158,10 +155,7 @@ def log_and_raise_value_error_if_option_not_in_block(option: str, block: Block) def log_and_raise_if_value_of_option_in_block_is_empty(value: str, option: str, block: Block) -> None: if not value: line_number = get_source_line_number_for_option(option, block) - s_error = 'Error in File "{source_file}", Line {line_number}: option "{option}" has no value'.format( - source_file=block.source, - line_number=line_number, - option=option) + s_error = f'Error in File "{block.source}", Line {line_number}: option "{option}" has no value' lib_log_utils.log_error(s_error) raise ValueError(s_error) @@ -169,9 +163,6 @@ def log_and_raise_if_value_of_option_in_block_is_empty(value: str, option: str, def log_and_raise_if_value_of_option_in_block_must_be_int_castable_but_is_not(value: str, option: str, block: Block, value_must_be_int: bool) -> None: if value_must_be_int and not value.isdigit(): line_number = get_source_line_number_for_option(option, block) - s_error = 'Error in File "{source_file}", Line {line_number}: option "{option}" has to be integer'.format( - source_file=block.source, - line_number=line_number, - option=option) + s_error = f'Error in File "{block.source}", Line {line_number}: option "{option}" has to be integer' lib_log_utils.log_error(s_error) raise TypeError(s_error) diff --git a/rst_include/libs/lib_check_files.py b/rst_include/libs/lib_check_files.py index 3a71b82..9f332b9 100644 --- a/rst_include/libs/lib_check_files.py +++ b/rst_include/libs/lib_check_files.py @@ -102,7 +102,7 @@ def log_and_raise_if_source_file_not_ok(source: Union[str, pathlib.Path, IO[str] if isinstance(source, pathlib.Path): if not source.is_file(): - error_message = 'RST File "{source}" does not exist'.format(source=source) + error_message = f'RST File "{source}" does not exist' lib_log_utils.log_error(error_message) raise FileNotFoundError(error_message) @@ -138,7 +138,7 @@ def log_and_raise_if_source_file_equals_target_file(source: Union[str, pathlib.P """ if isinstance(source, pathlib.Path) and source == target: - error_message = 'RST File "{source}": source and target must not be the same'.format(source=source) + error_message = f'RST File "{source}": source and target must not be the same' lib_log_utils.log_error(error_message) raise FileExistsError(error_message) @@ -157,7 +157,7 @@ def log_warning_if_target_file_exist(path_target: Union[str, pathlib.Path, IO[st """ if isinstance(path_target, pathlib.Path): if path_target.is_file(): - lib_log_utils.log_warning('RST File "{target}" exists and will be overwritten'.format(target=path_target)) + lib_log_utils.log_warning(f'RST File "{path_target}" exists and will be overwritten') def read_input(source: Union[str, pathlib.Path, IO[str]], encoding: str = 'utf-8-sig') -> str: diff --git a/rst_include/libs/lib_get_include_options.py b/rst_include/libs/lib_get_include_options.py index f8e5c33..489061a 100644 --- a/rst_include/libs/lib_get_include_options.py +++ b/rst_include/libs/lib_get_include_options.py @@ -121,8 +121,7 @@ def get_include_filename(block: Block) -> Tuple[pathlib.Path, pathlib.Path]: include_line = block.l_source_lines[0].content include_filename = include_line.split('.. include::')[1].strip() if not include_filename: - s_error = 'Error in File "{source_file}", Line {line_number}: no include filename'.format( - source_file=block.source, line_number=block.l_source_lines[0].line_number) + s_error = f'Error in File "{block.source}", Line {block.l_source_lines[0].line_number}: no include filename' lib_log_utils.log_error(s_error) raise FileNotFoundError(s_error) @@ -137,10 +136,7 @@ def get_include_filename(block: Block) -> Tuple[pathlib.Path, pathlib.Path]: path_include_file_absolut = (pathlib.Path.cwd() / path_include_file).resolve() if not path_include_file_absolut.is_file(): - s_error = 'Error in File "{source_file}", Line {line_number}: include File "{include_filename}" does not exist'.format( - source_file=block.source, - line_number=block.l_source_lines[0].line_number, - include_filename=path_include_file) + s_error = f'Error in File "{block.source}", Line {block.l_source_lines[0].line_number}: include File "{path_include_file}" does not exist' lib_log_utils.log_error(s_error) raise FileNotFoundError(s_error) block.include_filename = path_include_file diff --git a/rst_include/libs/lib_include_file.py b/rst_include/libs/lib_include_file.py index adfc058..0e71ce5 100644 --- a/rst_include/libs/lib_include_file.py +++ b/rst_include/libs/lib_include_file.py @@ -73,10 +73,8 @@ def read_include_file(block: Block) -> List[str]: return include_file_lines except FileNotFoundError: - s_error = 'Error in File "{source_file}", Line {line_number}: File not found : '\ - '"{include_file}"'.format(source_file=block.source, - line_number=block.l_source_lines[0].line_number, - include_file=block.include_filename_absolut) + s_error = f'Error in File "{block.source}", Line {block.l_source_lines[0].line_number}: File not found : '\ + '"{block.include_filename_absolut}"' lib_log_utils.log_traceback.log_exception_traceback(s_error) raise IOError(s_error) @@ -223,11 +221,8 @@ def slice_include_file_markers(block: Block) -> None: def log_and_raise_if_start_after_not_found_in_string(content: str, block: Block) -> None: if block.include_file_start_after not in content: - s_error = 'Error in File "{source_file}", Line {line_number}: include File "{include_filename}" : start-after "{start_after}" not found'.format( - source_file=block.source, - line_number=block.l_source_lines[0].line_number, - include_filename=block.include_filename, - start_after=block.include_file_start_after) + s_error = f'Error in File "{block.source}", Line {block.l_source_lines[0].line_number}: '\ + f'include File "{block.include_filename}" : start-after "{block.include_file_start_after}" not found' s_error = s_error + get_additional_error_string(block) lib_log_utils.log_error(s_error) raise ValueError(s_error) @@ -235,11 +230,8 @@ def log_and_raise_if_start_after_not_found_in_string(content: str, block: Block) def log_and_raise_if_end_before_not_found_in_string(content: str, block: Block) -> None: if block.include_file_end_before not in content: - s_error = 'Error in File "{source_file}", Line {line_number}: include File "{include_filename}" : end-before "{end_before}" not found'.format( - source_file=block.source, - line_number=block.l_source_lines[0].line_number, - include_filename=block.include_filename, - end_before=block.include_file_end_before) + s_error = f'Error in File "{block.source}", Line {block.l_source_lines[0].line_number}: ' \ + f'include File "{block.include_filename}" : end-before "{block.include_file_end_before}" not found' s_error = s_error + get_additional_error_string(block) s_error = s_error + get_additional_error_string_start_after(block) lib_log_utils.log_error(s_error) @@ -249,17 +241,16 @@ def log_and_raise_if_end_before_not_found_in_string(content: str, block: Block) def get_additional_error_string(block: Block) -> str: s_error = '' if block.include_file_start_line and block.include_file_end_line: - s_error = s_error + ' between start_line: {start_line} and end_line: {end_line}'.format( - start_line=block.include_file_start_line, end_line=block.include_file_end_line) + s_error = s_error + f' between start_line: {block.include_file_start_line} and end_line: {block.include_file_end_line}' elif block.include_file_start_line: - s_error = s_error + ' after start-line: {start_line}'.format(start_line=block.include_file_start_line) + s_error = s_error + f' after start-line: {block.include_file_start_line}' elif block.include_file_end_line: - s_error = s_error + ' before end-line: {end_line}'.format(end_line=block.include_file_end_line) + s_error = s_error + f' before end-line: {block.include_file_end_line}' return s_error def get_additional_error_string_start_after(block: Block) -> str: s_error = '' if block.include_file_start_after: - s_error = s_error + ' after start-after: {start_after}'.format(start_after=block.include_file_start_after) + s_error = s_error + f' after start-after: {block.include_file_start_after}' return s_error diff --git a/rst_include/libs/lib_test_compare_results.py b/rst_include/libs/lib_test_compare_results.py index 0bb6024..7635b81 100644 --- a/rst_include/libs/lib_test_compare_results.py +++ b/rst_include/libs/lib_test_compare_results.py @@ -67,22 +67,15 @@ def read_files_into_lines(expected_file: pathlib.Path, def log_file_lengths_not_equal(expected_file: pathlib.Path, result_file: pathlib.Path, len_expected_lines: int, len_result_lines: int) -> None: - lib_log_utils.log_error('Different Size, Expected File {expected_file}: {len_expected_lines} ' - 'Lines, Result File {result_file}: {len_result_lines} Lines'.format(expected_file=expected_file, - len_expected_lines=len_expected_lines, - result_file=result_file, - len_result_lines=len_result_lines)) + lib_log_utils.log_error(f'Different Size, Expected File {expected_file}: {len_expected_lines} ' + f'Lines, Result File {result_file}: {len_result_lines} Lines') def log_difference_expected_line(expected_file: pathlib.Path, line_number: int, expected_line: str) -> None: - lib_log_utils.log_error('Difference, Expected File {expected_file}, Line {line_number}: "{expected_line}"'.format( - expected_file=expected_file, - line_number=line_number, - expected_line=expected_line.replace('\n', ''))) + expected_line = expected_line.replace('\n', '') + lib_log_utils.log_error(f'Difference, Expected File {expected_file}, Line {line_number}: "{expected_line}"') def log_difference_result_line(result_file: pathlib.Path, line_number: int, result_line: str) -> None: - lib_log_utils.log_error('Difference, Result File {result_file}, Line {line_number}: "{result_line}"'.format( - result_file=result_file, - line_number=line_number, - result_line=result_line.replace('\n', ''))) + result_line = result_line.replace('\n', '') + lib_log_utils.log_error(f'Difference, Result File {result_file}, Line {line_number}: "{result_line}"') diff --git a/rst_include/rst_include.py b/rst_include/rst_include.py index dc96f0e..334bdcd 100644 --- a/rst_include/rst_include.py +++ b/rst_include/rst_include.py @@ -96,13 +96,13 @@ def import_module_from_file(module_fullpath: Union[pathlib.Path, str], reload: b spec = importlib.util.spec_from_file_location(module_name, module_fullpath) if spec is None: sys.path.pop() - raise ImportError('can not get spec from file location "{}"'.format(module_fullpath)) + raise ImportError(f'can not get spec from file location "{module_fullpath}"') try: mod = importlib.util.module_from_spec(spec) sys.modules[module_name] = mod except Exception as exc: - raise ImportError('can not load module "{}"'.format(module_name)) from exc + raise ImportError(f'can not load module "{module_name}"') from exc finally: sys.path.pop() sys.path.append(str(module_fullpath.parent)) @@ -111,7 +111,7 @@ def import_module_from_file(module_fullpath: Union[pathlib.Path, str], reload: b spec.loader.exec_module(mod) # type: ignore except Exception as exc: sys.path.pop() - raise ImportWarning('module "{}" reloaded, but can not be executed'.format(module_name)) from exc + raise ImportWarning(f'module "{module_name}" reloaded, but can not be executed') from exc return mod diff --git a/setup.py b/setup.py index 61b157d..d23b6d3 100644 --- a/setup.py +++ b/setup.py @@ -86,7 +86,7 @@ def get_line_data(line: str) -> str: setup_kwargs: Dict[str, Any] = dict() setup_kwargs["name"] = "rst_include" -setup_kwargs["version"] = "v2.1.0" +setup_kwargs["version"] = "v2.1.1" setup_kwargs["url"] = "https://github.com/bitranox/rst_include" setup_kwargs["packages"] = find_packages() setup_kwargs["package_data"] = {"rst_include": ["py.typed", "*.pyi", "__init__.pyi"]} diff --git a/tests/local_testscripts/lib_bash_functions.sh b/tests/local_testscripts/lib_bash_functions.sh index b65a516..a3d91d8 100644 --- a/tests/local_testscripts/lib_bash_functions.sh +++ b/tests/local_testscripts/lib_bash_functions.sh @@ -114,6 +114,18 @@ function cleanup() { } +function run_black() { + # run black for *.py files + my_banner "running black with settings from ${project_root_dir}/pyproject.toml" + if ! python3 -m black "${project_root_dir}"/**/*.py; then + my_banner_warning "black ERROR" + beep + sleep "${sleeptime_on_error}" + return 1 + fi +} + + function run_flake8_tests() { # run flake8, settings from setup.cfg my_banner "running flake8 with settings from ${project_root_dir}/setup.cfg" diff --git a/tests/local_testscripts/run_testloop.sh b/tests/local_testscripts/run_testloop.sh index 222d298..2eb5b6a 100644 --- a/tests/local_testscripts/run_testloop.sh +++ b/tests/local_testscripts/run_testloop.sh @@ -13,6 +13,7 @@ project_root_dir="${project_root_dir}" DO_FLAKE8_TESTS="True" DO_MYPY_TESTS="True" DO_PYTEST="True" +DO_BLACK="False" # cleanup on cntrl-c trap cleanup EXIT @@ -24,6 +25,10 @@ function pytest_loop { banner "Project Root Dir: ${project_root_dir}" cleanup + if [ "${DO_BLACK}" == "True" ]; then + if ! run_black; then continue; fi + fi + # we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins if [ "${DO_FLAKE8_TESTS}" == "True" ]; then if ! run_flake8_tests; then continue; fi