Skip to content

Commit 79b214e

Browse files
committed
reduce diff
1 parent 025346f commit 79b214e

File tree

3 files changed

+24
-42
lines changed

3 files changed

+24
-42
lines changed

ni_python_styleguide/_cli.py

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import pathlib
32
import sys
43
import typing
@@ -8,9 +7,6 @@
87

98
from ni_python_styleguide import _acknowledge_existing_errors, _fix, _Flake8Error, _lint
109

11-
_logger = logging.getLogger(__name__)
12-
_logger.addHandler(logging.NullHandler())
13-
1410

1511
def _qs_or_vs(verbosity):
1612
if verbosity != 0:
@@ -161,17 +157,13 @@ def acknowledge_existing_violations(obj, extend_ignore, file_or_dir, aggressive)
161157
162158
Use this command to acknowledge violations in existing code to allow for enforcing new code.
163159
"""
164-
try:
165-
_acknowledge_existing_errors.acknowledge_lint_errors(
166-
exclude=obj["EXCLUDE"],
167-
app_import_names=obj["APP_IMPORT_NAMES"],
168-
extend_ignore=extend_ignore,
169-
file_or_dir=file_or_dir,
170-
aggressive=aggressive,
171-
)
172-
except Exception as e:
173-
_logger.debug(e, exc_info=True)
174-
raise click.ClickException(f"Error occurred: {e}")
160+
_acknowledge_existing_errors.acknowledge_lint_errors(
161+
exclude=obj["EXCLUDE"],
162+
app_import_names=obj["APP_IMPORT_NAMES"],
163+
extend_ignore=extend_ignore,
164+
file_or_dir=file_or_dir,
165+
aggressive=aggressive,
166+
)
175167

176168

177169
@main.command()
@@ -189,17 +181,13 @@ def acknowledge_existing_violations(obj, extend_ignore, file_or_dir, aggressive)
189181
@click.pass_obj
190182
def fix(obj, extend_ignore: typing.Optional[str], file_or_dir, aggressive):
191183
"""Fix basic linter/formatting errors in file(s)/directory(s) given."""
192-
try:
193-
_fix.fix(
194-
exclude=obj["EXCLUDE"],
195-
app_import_names=obj["APP_IMPORT_NAMES"],
196-
extend_ignore=extend_ignore,
197-
file_or_dir=file_or_dir or [pathlib.Path.cwd()],
198-
aggressive=aggressive,
199-
)
200-
except Exception as e:
201-
_logger.debug(e, exc_info=True)
202-
raise click.ClickException(f"Error occurred: {e}")
184+
_fix.fix(
185+
exclude=obj["EXCLUDE"],
186+
app_import_names=obj["APP_IMPORT_NAMES"],
187+
extend_ignore=extend_ignore,
188+
file_or_dir=file_or_dir or [pathlib.Path.cwd()],
189+
aggressive=aggressive,
190+
)
203191

204192

205193
@main.command()
@@ -209,16 +197,12 @@ def fix(obj, extend_ignore: typing.Optional[str], file_or_dir, aggressive):
209197
@click.pass_obj
210198
def format(obj, file_or_dir, check: bool, diff: bool):
211199
"""Format the file(s)/directory(s) given."""
212-
try:
213-
_fix.fix(
214-
exclude=obj["EXCLUDE"],
215-
app_import_names=obj["APP_IMPORT_NAMES"],
216-
extend_ignore=None,
217-
file_or_dir=file_or_dir or [pathlib.Path.cwd()],
218-
aggressive=False,
219-
check=check,
220-
diff=diff,
221-
)
222-
except Exception as e:
223-
_logger.debug(e, exc_info=True)
224-
raise click.ClickException(f"Error occurred: {e}")
200+
_fix.fix(
201+
exclude=obj["EXCLUDE"],
202+
app_import_names=obj["APP_IMPORT_NAMES"],
203+
extend_ignore=None,
204+
file_or_dir=file_or_dir or [pathlib.Path.cwd()],
205+
aggressive=False,
206+
check=check,
207+
diff=diff,
208+
)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from . import _constants
21
from . import code_analysis # noqa: F401
32
from . import lint # noqa: F401
43
from . import string_helpers # noqa: F401
54
from . import temp_file # noqa: F401
65

7-
DEFAULT_ENCODING = _constants.DEFAULT_ENCODING
6+
DEFAULT_ENCODING = "UTF-8"

ni_python_styleguide/_utils/_constants.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)