-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of global
state
(not lexer state yet) (#155)
- Loading branch information
Showing
19 changed files
with
366 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
"""This module contains global state of flynt application instance.""" | ||
|
||
quiet = False | ||
aggressive = False | ||
dry_run = False | ||
import dataclasses | ||
from typing import Optional | ||
|
||
percent_candidates = 0 | ||
percent_transforms = 0 | ||
|
||
call_candidates = 0 | ||
call_transforms = 0 | ||
@dataclasses.dataclass | ||
class State: | ||
# -- Options | ||
quiet: bool = False | ||
aggressive: bool = False | ||
dry_run: bool = False | ||
multiline: bool = True | ||
len_limit: Optional[int] = None | ||
transform_percent: bool = True | ||
transform_format: bool = True | ||
transform_concat: bool = False | ||
transform_join: bool = False | ||
|
||
invalid_conversions = 0 | ||
# -- Statistics | ||
percent_candidates: int = 0 | ||
percent_transforms: int = 0 | ||
|
||
concat_candidates = 0 | ||
concat_changes = 0 | ||
call_candidates: int = 0 | ||
call_transforms: int = 0 | ||
|
||
join_candidates = 0 | ||
join_changes = 0 | ||
invalid_conversions: int = 0 | ||
|
||
# Backup of the initial state to support the tests, which should start with a clean state each time. | ||
# Note: this assumes that all state variables are immutable. | ||
_initial_state = dict(globals()) | ||
concat_candidates: int = 0 | ||
concat_changes: int = 0 | ||
|
||
|
||
def _reset() -> None: | ||
""" | ||
Resets the state variables to the initial values seen above. | ||
""" | ||
globals().update(**_initial_state) | ||
join_candidates: int = 0 | ||
join_changes: int = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.