Skip to content

Sourcery refactored master branch #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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 26, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from tnmygrwl July 26, 2023 20:30
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery timed out performing refactorings.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -12 to -13

setup(name="plotly")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 12-13 refactored with the following changes:

Comment on lines -28 to +31
# print(submodules_str)

autosubmodule = ""

for submodule in submodules:
autosubmodule += (
".. automodule:: plotly.graph_objects.%s\n :members:\n\n" % submodule
)
autosubmodule = "".join(
(".. automodule:: plotly.graph_objects.%s\n :members:\n\n" % submodule)
for submodule in submodules
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-35 refactored with the following changes:

  • Use str.join() instead of for loop (use-join)

This removes the following comments ( why? ):

# print(submodules_str)

"{} is not a valid config or credentials key".format(key)
f"{key} is not a valid config or credentials key"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sign_in refactored with the following changes:

Comment on lines -126 to +134
"{} is not a valid config or plot option key".format(key)
f"{key} is not a valid config or plot option key"
)
if not isinstance(kwargs[key], PLOT_OPTIONS[key]):
raise _plotly_utils.exceptions.PlotlyError(
"{} must be of type '{}'".format(key, PLOT_OPTIONS[key])
f"{key} must be of type '{PLOT_OPTIONS[key]}'"
)

# raise exception if sharing is invalid
if key == "sharing" and not (kwargs[key] in SHARING_OPTIONS):
if key == "sharing" and kwargs[key] not in SHARING_OPTIONS:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update_session_plot_options refactored with the following changes:

# to check for share_key we check urlsplit.query
query_dict = six.moves.urllib.parse.parse_qs(urlsplit.query)
if query_dict:
if query_dict := six.moves.urllib.parse.parse_qs(urlsplit.query):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_embed_url refactored with the following changes:

This removes the following comments ( why? ):

# to check for share_key we check urlsplit.query

Comment on lines -53 to +51
container = {
return {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _container refactored with the following changes:

Comment on lines -298 to +294
# remove path 'second' as it's always an empty box
all_paths = []
for node in all_nodes:
all_paths.append(node[1])
all_paths = [node[1] for node in all_nodes]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Dashboard._make_all_nodes_and_paths refactored with the following changes:

This removes the following comments ( why? ):

# remove path 'second' as it's always an empty box

Comment on lines +408 to -418
new_top_left_x = top_left_x
new_top_left_y = top_left_y
# determine the specs for resulting two box split
if is_horizontal:
new_top_left_x = top_left_x
new_top_left_y = top_left_y
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Dashboard.get_preview refactored with the following changes:

if len(jdata) > max_chars:
data_string = jdata[:max_chars] + "...]"
else:
data_string = jdata
data_string = f"{jdata[:max_chars]}...]" if len(jdata) > max_chars else jdata
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Column.__str__ refactored with the following changes:

Comment on lines -161 to +167
duplicate_name = utils.get_first_duplicate(columns_or_json.columns)
if duplicate_name:
if duplicate_name := utils.get_first_duplicate(
columns_or_json.columns
):
err = exceptions.NON_UNIQUE_COLUMN_MESSAGE.format(duplicate_name)
raise exceptions.InputError(err)

# create columns from dataframe
all_columns = []
for name in columns_or_json.columns:
all_columns.append(Column(columns_or_json[name].tolist(), name))
all_columns = [
Column(columns_or_json[name].tolist(), name)
for name in columns_or_json.columns
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Grid.__init__ refactored with the following changes:

This removes the following comments ( why? ):

# collect and sort all orders in case orders do not start
# create columns from dataframe
# at zero or there are jump discontinuities between them

Comment on lines -286 to +287
column_id = None
for column in self._columns:
if column.name == column_name:
column_id = column.id
break

column_id = next(
(column.id for column in self._columns if column.name == column_name),
None,
)
if column_id is None:
col_names = []
for column in self._columns:
col_names.append(column.name)
col_names = [column.name for column in self._columns]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Grid.get_column_reference refactored with the following changes:

user_plot_options.update(default_plot_options)
user_plot_options |= default_plot_options
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _plot_option_logic refactored with the following changes:

embed_options = dict()
embed_options["width"] = layout.get("width", "100%")
embed_options = {"width": layout.get("width", "100%")}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function iplot refactored with the following changes:

Comment on lines -236 to +239
filename = filename[0:-1]
filename = filename[:-1]

# split off any parent directory
paths = filename.split("/")
parent_path = "/".join(paths[0:-1])
parent_path = "/".join(paths[:-1])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function plot refactored with the following changes:

This removes the following comments ( why? ):

# Handle auto_open

Comment on lines -410 to +407
data_obj["z"] = [[0 for rrr in range(rows)] for ccc in range(cols)]
data_obj["z"] = [[0 for _ in range(rows)] for _ in range(cols)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _swap_xy_data refactored with the following changes:

Comment on lines -1398 to +1379
fid = "{}:{}".format(username, idlocal)
fid = f"{username}:{idlocal}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function add_share_key_to_url refactored with the following changes:

Comment on lines -1433 to +1413
if raw:
return parsed_content
return Grid(parsed_content, fid)
return parsed_content if raw else Grid(parsed_content, fid)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_grid refactored with the following changes:

Comment on lines -1453 to +1431
api_module = getattr(v2, filetype + "s")
api_module = getattr(v2, f"{filetype}s")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _create_or_update refactored with the following changes:

Comment on lines -1635 to -1641
if sharing == "public":
world_readable = True
elif sharing == "private":
if sharing in ["private", "secret"]:
world_readable = False
elif sharing == "secret":
world_readable = False

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dashboard_ops.upload refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

Comment on lines -1662 to +1640
dashboards = []
res = v2.dashboards.list().json()

for dashboard in res["results"]:
if not dashboard["deleted"]:
dashboards.append(dashboard)
dashboards = [
dashboard for dashboard in res["results"] if not dashboard["deleted"]
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dashboard_ops._get_all_dashboards refactored with the following changes:

Comment on lines -1686 to +1659
if only_content:
dashboard_json = json.loads(dashboard["content"])
return dashboard_json
else:
return dashboard
return json.loads(dashboard["content"]) if only_content else dashboard
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function dashboard_ops._get_dashboard_json refactored with the following changes:

Comment on lines -1783 to +1752
propsrc = "{}src".format(prop)
propsrc = f"{prop}src"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _extract_grid_graph_obj refactored with the following changes:

Comment on lines -1856 to +1825
raise ValueError("Invalid figure type {}".format(type(fig)))
raise ValueError(f"Invalid figure type {type(fig)}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _extract_grid_from_fig_like refactored with the following changes:

Comment on lines -1906 to +1873
prop_parent[prop_path[-1] + "src"] = col.id
prop_parent[f"{prop_path[-1]}src"] = col.id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _set_grid_column_references refactored with the following changes:

Comment on lines -2100 to +2067
embed_options = dict()
embed_options["width"] = layout.get("width", "100%")
embed_options = {"width": layout.get("width", "100%")}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function icreate_animations refactored with the following changes:

Comment on lines -422 to +412
if grouptype == "rightgroup_v":
left_shift = 100 - width_range
else:
left_shift = 0

left_shift = 100 - width_range if grouptype == "rightgroup_v" else 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _box_specs_gen refactored with the following changes:

Comment on lines -544 to +517
if num_of_boxes == 0 and slide_num == 0:
text_textAlign = "center"
else:
text_textAlign = "left"
text_textAlign = "center" if num_of_boxes == 0 and slide_num == 0 else "left"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _return_layout_specs refactored with the following changes:

This removes the following comments ( why? ):

# left
# middle across

Comment on lines -894 to +868
return line.startswith(url_name + "(") and line.endswith(")")
return line.startswith(f"{url_name}(") and line.endswith(")")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _url_parens_contained refactored with the following changes:

expected_message = (
"Yikes, plotly grids currently "
"can't have duplicate column names. Rename "
'the column "{}" and try again.'.format("col_1")
)
expected_message = """Yikes, plotly grids currently can't have duplicate column names. Rename the column "col_1" and try again."""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TestDataframeToGrid.test_duplicate_columns refactored with the following changes:

self.assertEqual(url, "{}/v2/files/hodor:88".format(self.plotly_api_domain))
self.assertEqual(url, f"{self.plotly_api_domain}/v2/files/hodor:88")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FilesTest.test_retrieve refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants