Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ __pycache__/

# Generated by build
/dist

# IDEs configs/caches
.vscode
.idea
.run
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dev = [
"pytest",
"pytest-cov",
"twine",
"ruff",
]

[project.scripts]
Expand Down
17 changes: 8 additions & 9 deletions src/flynt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import sys
import time
import traceback
from difflib import unified_diff
from typing import Collection, List, Optional, Tuple

Expand Down Expand Up @@ -100,10 +99,10 @@ def fstringify_code(
new_code,
state=state,
)
except Exception:
msg = traceback.format_exc()
log.error("Transforming concatenation of literal strings failed")
log.error(msg)
except Exception as exc:
log.error(
"Transforming concatenation of literal strings failed", exc_info=exc
)
else:
changes += concat_changes
state.concat_changes += concat_changes
Expand All @@ -113,10 +112,10 @@ def fstringify_code(
new_code,
state=state,
)
except Exception:
msg = traceback.format_exc()
log.error("Transforming concatenation of literal strings failed")
log.error(msg)
except Exception as exc:
log.error(
"Transforming concatenation of literal strings failed", exc_info=exc
)
else:
changes += join_changes
state.join_changes += join_changes
Expand Down
10 changes: 6 additions & 4 deletions src/flynt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def run_flynt_cli(arglist: Optional[List[str]] = None) -> int:
verbosity_group.add_argument(
"-v",
"--verbose",
action="store_true",
action="count",
help="run with verbose output",
default=False,
default=0,
)
verbosity_group.add_argument(
"-q",
Expand Down Expand Up @@ -194,8 +194,10 @@ def run_flynt_cli(arglist: Optional[List[str]] = None) -> int:
)

state = state_from_args(args)
if args.verbose:
logging.getLogger("flynt").setLevel(logging.DEBUG)
if args.verbose > 0:
logging.getLogger("flynt").setLevel(
logging.DEBUG if args.verbose > 1 else logging.INFO
)

if args.string:
content = " ".join(args.src)
Expand Down
7 changes: 3 additions & 4 deletions src/flynt/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ast
import copy
import logging
import traceback
from typing import Tuple

from flynt.exceptions import ConversionRefused
Expand Down Expand Up @@ -38,9 +37,9 @@ def transform_chunk(
log.warning("Not converting code due to: %s", cr)
state.invalid_conversions += 1
return None, False # type:ignore # ideally should return one optional str
except Exception:
msg = traceback.format_exc()
log.exception("Exception during conversion of code: %s", msg)
except Exception as exc:
level = logging.DEBUG if isinstance(exc, AssertionError) else logging.ERROR
log.log(level, "Exception during conversion of code", exc_info=exc)
state.invalid_conversions += 1
return None, False # type:ignore # ideally should return one optional str
else:
Expand Down
Loading