-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2023-06-01 v01.00.004-001-Alpha: Edit Mode Feature Testing (Sourcery refactored) #42
base: main
Are you sure you want to change the base?
Conversation
app.py
Outdated
def mode(ctx, param, value) \ | ||
-> str | None: # noqa Contexts, Parameters uses in callbacks | ||
def mode(ctx, param, value) -> str | None: # noqa Contexts, Parameters uses in callbacks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Valid.mode
refactored with the following changes:
- Replace f-string with no interpolated values with string [×2] (
remove-redundant-fstring
)
This removes the following comments ( why? ):
# Exit Edit Mode: Automatically exit Editing Mode.
# Enter Delete Edit Mode: To clear, remove existing record's value.
# Enter Update Edit Mode: To append, update, new inputs to existing.
app.py
Outdated
def checkcommand(mode: str) \ | ||
-> str | None: | ||
def checkcommand(mode: str) -> str | None: | ||
"""Check the mode, translate to edit comand tyoe.""" | ||
allowed = {App.values.Edit.ADD, | ||
App.values.Edit.UPDATE, App.values.Edit.DELETE} | ||
if mode in allowed: | ||
if mode == App.values.Edit.ADD: | ||
return App.values.Edit.INSERT | ||
elif mode == App.values.Edit.UPDATE: | ||
return App.values.Edit.APPEND | ||
elif mode == App.values.Edit.DELETE: | ||
return App.values.Edit.CLEAR | ||
else: | ||
if mode not in allowed: | ||
return None | ||
if mode == App.values.Edit.ADD: | ||
return App.values.Edit.INSERT | ||
elif mode == App.values.Edit.UPDATE: | ||
return App.values.Edit.APPEND | ||
elif mode == App.values.Edit.DELETE: | ||
return App.values.Edit.CLEAR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Valid.checkcommand
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
app.py
Outdated
if debug is True: | ||
|
||
if debug: | ||
rprint("Debug Mode: Show Record") | ||
inspector(individual) | ||
|
||
if displayon: | ||
if individual.card(consolecard=Webconsole.console) is not None: | ||
window.printpanels(record=individual) | ||
else: | ||
click.echo("Displaying Simple Card") | ||
individual.card(consolecard=Webconsole.console) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Window.showrecord
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
) - Swap positions of nested conditionals (
swap-nested-ifs
) - Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if
)
app.py
Outdated
@click.option(f'-selects', 'selects', | ||
type=click.Choice(choices=App.views.Todo, | ||
case_sensitive=App.values.case), | ||
default=App.values.Todo.Selects.default, | ||
show_default=App.values.shown, | ||
prompt=App.values.Todo.Selects.prompt, | ||
help=App.values.Todo.Selects.help) | ||
@click.option('-selects', 'selects', type=click.Choice(choices=App.views.Todo, | ||
case_sensitive=App.values.case), default=App.values.Todo.Selects.default, show_default=App.values.shown, prompt=App.values.Todo.Selects.prompt, help=App.values.Todo.Selects.help) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function todo
refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring
)
controller.py
Outdated
debug: bool = True) \ | ||
-> pd.Series | pd.DataFrame | None: | ||
debug: bool = True) -> pd.Series | pd.DataFrame | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Results.getrowdata
refactored with the following changes:
- Simplify comparison to boolean [×2] (
simplify-boolean-comparison
)
controller.py
Outdated
if switch is True: | ||
if switch: | ||
return renderable | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Record.switch
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
)
controller.py
Outdated
location: int | None = None, debug=False) -> None: # noqa | ||
location: int | None = None, debug=False) -> None: # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Editor.modifynotes
refactored with the following changes:
- Replace f-string with no interpolated values with string [×3] (
remove-redundant-fstring
)
This removes the following comments ( why? ):
# EditMode is Append: then append the notes the Notes column
# EditMode is Clear: then clear the notes the Notes column
controller.py
Outdated
|
||
if series[column] == 'Add a note'.strip(): | ||
series[column] = cleared | ||
return series[column] | ||
|
||
def _haslabel() -> bool: | ||
"""Checks if the notes have a label""" | ||
return True if series[column].startswith('Add a note') else False | ||
return bool(series[column].startswith('Add a note')) | ||
|
||
def _emptydelete(clear: str = '') -> bool: | ||
"""Checks if the notes are empty""" | ||
if nodestroy is False and _haslabel() is False: | ||
return True if series[column] == clear else False | ||
elif nodestroy is True and _haslabel() is True: | ||
if not nodestroy and _haslabel() is False: | ||
return series[column] == clear | ||
elif nodestroy and _haslabel() is True: | ||
series[column] = _removelabel(clear) | ||
return True if series[column] == clear else False | ||
elif nodestroy is True and _haslabel() is False: | ||
return True if series[column] == clear else False | ||
elif nodestroy is True and _haslabel() is True: | ||
return series[column] == clear | ||
elif nodestroy and _haslabel() is False: | ||
return series[column] == clear | ||
elif nodestroy and _haslabel() is True: | ||
series[column] = _removelabel(clear) | ||
return True if series[column] == clear else False | ||
return series[column] == clear | ||
|
||
_cleared = '' | ||
if _emptydelete(_cleared): | ||
click.echo(message="No notes to delete") | ||
return series[column] | ||
elif nodestroy is False: | ||
elif not nodestroy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Editor.deletenotes
refactored with the following changes:
- Simplify boolean if expression [×5] (
boolean-if-exp-identity
) - Simplify comparison to boolean [×5] (
simplify-boolean-comparison
) - Remove unnecessary casts to int, str, float or bool [×4] (
remove-unnecessary-cast
)
controller.py
Outdated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Editor.togglestatus
refactored with the following changes:
- Simplify comparison to boolean (
simplify-boolean-comparison
)
controller.py
Outdated
vlue: str, | ||
ix: int, | ||
col: str) -> pd.DataFrame | None: | ||
vlue: str, | ||
ix: int, | ||
col: str) -> pd.DataFrame | None: | ||
"""Update the data at the index and column""" | ||
|
||
def _atindexcolumn(data, debg: bool, isz: bool): | ||
"""Update the data at the index and column""" | ||
data.at[ix, col] = vlue | ||
if isz and debug is True: | ||
if isz and debug: | ||
click.secho( | ||
message=f"_IXxCol: Note Updated at row: {ix} " | ||
"by zero index for " | ||
f"{record.series.name}", | ||
err=True) | ||
rich.inspect(data.at[ix, col]) | ||
elif not isz and debug is True: | ||
elif not isz and debug: | ||
click.secho( | ||
message="_IXxCol: Note Updated at nonzero'd" | ||
f" row: {ix} " | ||
f"by {record.series.name} only", | ||
err=True) | ||
rich.inspect(data.at[ix, col]) | ||
|
||
# Use the internal DF pointer if the index is not given | ||
if ix is None and col is not None: | ||
framedata.at[record.series.name, col] = vlue | ||
# Use the index of the row if the column is given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Editor.insert
refactored with the following changes:
- Simplify comparison to boolean [×6] (
simplify-boolean-comparison
)
This removes the following comments ( why? ):
# Use the index of the row if the column is given
# For If neither, return the original DataFrame, with no changes
# For subsequent column updates and reuse of the same updated DataFrame
87c5917
to
adba1a0
Compare
adba1a0
to
f670a64
Compare
Pull Request #41 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run:Help us improve this pull request!