-
Notifications
You must be signed in to change notification settings - Fork 13
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
Sourcery refactored master branch #6
base: master
Are you sure you want to change the base?
Conversation
tickers_str = "" | ||
t_number = len(tickers_list) | ||
for i, ticker in enumerate(tickers_list): | ||
tickers_str += f"{ticker}," if i + 1 < t_number else ticker | ||
tickers_str = "".join( | ||
f"{ticker}," if i + 1 < t_number else ticker | ||
for i, ticker in enumerate(tickers_list) | ||
) | ||
|
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 create_link
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Use str.join() instead of for loop (
use-join
)
div = html.Div( | ||
return html.Div( |
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 create_copy_link_div
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
info_table = dash_table.DataTable( | ||
return dash_table.DataTable( | ||
data=info_list, | ||
style_data={"whiteSpace": "normal", "height": "auto"}, | ||
) | ||
return info_table |
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 get_info
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
page = dbc.Container( | ||
return dbc.Container( | ||
[ | ||
dbc.Row( | ||
[ | ||
dbc.Col(card_controls(tickers, first_date, last_date, ccy), lg=7), | ||
dbc.Col( | ||
card_controls(tickers, first_date, last_date, ccy), | ||
lg=7, | ||
), |
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 layout
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
real = False if plot_type == "cagr" else True | ||
real = plot_type != "cagr" |
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 get_al_figure
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
is_correct_number = number in range(0, settings.MC_MAX) and isinstance(number, int) | ||
is_correct_number = number in range(settings.MC_MAX) and isinstance( | ||
number, int | ||
) | ||
|
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 check_validity_monte_carlo
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
page = dbc.Container( | ||
return dbc.Container( | ||
[ | ||
dbc.Row( | ||
[ | ||
dbc.Col(card_controls(tickers, first_date, last_date, ccy), lg=5), | ||
dbc.Col( | ||
card_controls(tickers, first_date, last_date, ccy), | ||
lg=5, | ||
), |
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 layout
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
real = False if plot_type == "cagr" else True | ||
real = plot_type != "cagr" |
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 get_pf_figure
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
# tickers_list = get_tickers_list(tickers) | ||
card = dbc.Card( | ||
return dbc.Card( | ||
dbc.CardBody( | ||
[ | ||
html.H5("Investment Portfolio", className="card-title"), | ||
html.Div( | ||
[ | ||
dbc.Row([ | ||
dbc.Col(html.Label("Tickers")), | ||
dbc.Col(html.Label("Weights")) | ||
]), | ||
dbc.Row( | ||
[ | ||
dbc.Col(html.Label("Tickers")), | ||
dbc.Col(html.Label("Weights")), | ||
] | ||
), | ||
html.Div(id='dynamic-container', children=[]), | ||
dbc.Row([ | ||
dbc.Col(dbc.Button("Add Asset", id="dynamic-add-filter", n_clicks=0)), | ||
dbc.Col(html.Div(id="pf-portfolio-weights-sum")) | ||
]), | ||
|
||
dbc.Row( | ||
[ | ||
dbc.Col( | ||
dbc.Button( | ||
"Add Asset", | ||
id="dynamic-add-filter", | ||
n_clicks=0, | ||
) | ||
), | ||
dbc.Col( | ||
html.Div(id="pf-portfolio-weights-sum") | ||
), | ||
] | ||
), |
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 card_controls
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Simplify if expression by using or [×3] (
or-if-exp-identity
)
This removes the following comments ( why? ):
# tickers_list = get_tickers_list(tickers)
# # copy link to clipboard button
# dbc.Row(
# button_id="pf-copy-link-button",
# create_copy_link_div(
# ),
# card_name="asset list",
# location_id="pf-url",
# ),
# hidden_div_with_url_id="pf-show-url",
not_allocated_weight = 100 - weights_sum if 100 - weights_sum > 0 else 0 | ||
not_allocated_weight = 100 - weights_sum if weights_sum < 100 else 0 |
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 generate_chart
refactored with the following changes:
- Simplify numeric comparison (
simplify-numeric-comparison
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.51%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
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
master
branch, then run:Help us improve this pull request!