Skip to content

Commit

Permalink
Merge pull request #110 from jedie/dev
Browse files Browse the repository at this point in the history
Fix "format file" and very verbose error output
  • Loading branch information
jedie authored Dec 5, 2023
2 parents 1686df2 + 3c667a3 commit 111af42
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ See also git tags: https://github.com/jedie/manageprojects/tags

[comment]: <> (✂✂✂ auto generated history start ✂✂✂)

* [v0.16.1](https://github.com/jedie/manageprojects/compare/v0.16.0...v0.16.1)
* 2023-12-05 - Fix "format file" and very verbose error output
* [v0.16.0](https://github.com/jedie/manageprojects/compare/v0.15.4...v0.16.0)
* 2023-12-02 - Use code style tooling from cli-base-utilities
* 2023-12-01 - Apply https://github.com/jedie/cookiecutter_templates updates
Expand All @@ -330,11 +332,11 @@ See also git tags: https://github.com/jedie/manageprojects/tags
* [v0.15.3](https://github.com/jedie/manageprojects/compare/v0.15.2...v0.15.3)
* 2023-11-09 - Bugfix "reverse" if context contains a list
* 2023-11-07 - Update requirements
* [v0.15.2](https://github.com/jedie/manageprojects/compare/v0.15.1...v0.15.2)
* 2023-11-01 - Update requirements

<details><summary>Expand older history entries ...</summary>

* [v0.15.2](https://github.com/jedie/manageprojects/compare/v0.15.1...v0.15.2)
* 2023-11-01 - Update requirements
* [v0.15.1](https://github.com/jedie/manageprojects/compare/v0.15.0...v0.15.1)
* 2023-10-08 - Update text matrix with Python v3.12
* 2023-10-08 - fix github CI
Expand Down
2 changes: 1 addition & 1 deletion manageprojects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Manage Python / Django projects
"""

__version__ = '0.16.0'
__version__ = '0.16.1'
__author__ = 'Jens Diemer <mamageprojects@jensdiemer.de>'
29 changes: 19 additions & 10 deletions manageprojects/format_file.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import dataclasses
import subprocess
from pathlib import Path
from typing import Optional

from bx_py_utils.dict_utils import dict_get
from cli_base.cli_tools.git import Git, GitError, NoGitRepoError
from cli_base.cli_tools.subprocess_utils import ToolsExecutor
from cli_base.cli_tools.subprocess_utils import ToolsExecutor as OriginalToolsExecutor
from editorconfig import EditorConfigError, get_properties
from packaging.specifiers import SpecifierSet
from packaging.version import Version
Expand All @@ -19,6 +20,14 @@
MAX_PY3_VER = 15


class ToolsExecutor(OriginalToolsExecutor):
def verbose_check_call(self, *args, **kwargs):
try:
super().verbose_check_call(*args, **kwargs)
except subprocess.CalledProcessError:
pass # Info print is already done


@dataclasses.dataclass
class GitInfo:
cwd: Path
Expand Down Expand Up @@ -152,7 +161,7 @@ def get_config(

def run_pyupgrade(tools_executor, file_path, config):
pyver_arg = f'--{config.py_ver_str}-plus'
tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'pyupgrade',
'--exit-zero-even-if-changed',
pyver_arg,
Expand All @@ -166,7 +175,7 @@ def run_autoflake(tools_executor, file_path, config, remove_all_unused_imports):
if remove_all_unused_imports:
args.append('--remove-all-unused-imports')
args.append(file_path)
tools_executor.verbose_check_output(*args)
tools_executor.verbose_check_call(*args)


def run_darker(tools_executor, file_path, config, darker_prefixes):
Expand All @@ -175,7 +184,7 @@ def run_darker(tools_executor, file_path, config, darker_prefixes):
# "E302 expected 2 blank lines"
# "E303 too many blank lines (4)"
# work-a-round: run autopep8 only for these fixes ;)
tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'autopep8',
'--ignore-local-config',
'--select',
Expand All @@ -185,7 +194,7 @@ def run_darker(tools_executor, file_path, config, darker_prefixes):
str(file_path),
)

tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'darker',
'--flynt',
'--isort',
Expand All @@ -201,7 +210,7 @@ def run_darker(tools_executor, file_path, config, darker_prefixes):


def run_autopep8(tools_executor, file_path, config):
tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'autopep8',
'--ignore-local-config',
'--max-line-length',
Expand All @@ -214,7 +223,7 @@ def run_autopep8(tools_executor, file_path, config):


def run_flake8(tools_executor, file_path, config):
tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'flake8',
'--max-line-length',
str(config.max_line_length),
Expand All @@ -223,15 +232,15 @@ def run_flake8(tools_executor, file_path, config):


def run_pyflakes(tools_executor, file_path, config):
tools_executor.verbose_check_output('pyflakes', file_path)
tools_executor.verbose_check_call('pyflakes', file_path)


def run_codespell(tools_executor, file_path, config):
tools_executor.verbose_check_output('codespell', file_path)
tools_executor.verbose_check_call('codespell', file_path)


def run_mypy(tools_executor, file_path, config):
tools_executor.verbose_check_output(
tools_executor.verbose_check_call(
'mypy',
'--ignore-missing-imports',
'--follow-imports',
Expand Down

0 comments on commit 111af42

Please sign in to comment.