-
Notifications
You must be signed in to change notification settings - Fork 14k
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
fix: remove standalone #18157
Merged
Merged
fix: remove standalone #18157
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e83a9b8
removed standalone
AAfghahi 3e75c14
Update tests/integration_tests/reports/commands_tests.py
AAfghahi ca2b881
changed standalone
AAfghahi 602ebba
changed standalone
AAfghahi 565e2c1
added tests
AAfghahi 89d7e58
made function more generic
AAfghahi 8c7e2f8
Update superset/reports/notifications/email.py
AAfghahi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from superset.utils.urls import get_screenshot_explorelink | ||
|
||
EXPLORE_CHART_LINK = "http://localhost:9000/superset/explore/?form_data=%7B%22slice_id%22%3A+76%7D&standalone=true&force=false" | ||
|
||
EXPLORE_DASHBOARD_LINK = "http://localhost:9000/superset/dashboard/3/?standalone=3" | ||
|
||
|
||
def test_convert_chart_link() -> None: | ||
test_url = get_screenshot_explorelink(EXPLORE_CHART_LINK) | ||
assert ( | ||
test_url | ||
== "http://localhost:9000/superset/explore/?form_data=%7B%22slice_id%22%3A%2076%7D&standalone=0&force=false" | ||
) | ||
|
||
|
||
def test_convert_dashboard_link() -> None: | ||
test_url = get_screenshot_explorelink(EXPLORE_DASHBOARD_LINK) | ||
assert test_url == "http://localhost:9000/superset/dashboard/3/?standalone=0" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you add a docstring to the function explaining what it does? As for types, it's better to have the signature be
(url: str) -> str:
, otherwise you need to handle the case whereurl
isNone
.One thing I was thinking is that since this function is currently very specific we could make it a bit more generic, so it has utility outside of your use case. Eg:
Then you can call it for your use case as:
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.
ok I think that is a cool generic function, thank you! When I had
(url: string) -> string
I got a type error, and since i was rushing against the cherry deadline I made it optional, will change back and think it through. Thank you!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.
If you had an error with
(url: str) -> str
it means that in some place the function was potentially being called with a non-string value (probablyNone
, since you fixed it by addingOptional
). Since your original function did not handle the case when the argument was not a string, this means that at some point the code would break.In other words, if your function has a signature
(url: Optional[str])
it should be able to handle being passedurl=None
. But more importantly, the types in the signature should make sense — would we ever want to passNone
as a URL to a function that changes parameters in the URL?The proper way to fix the type checking is not relaxing the signature, but adding guards to the code:
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.
I was thinking of adding an exception into the modify_url_query function, but this feels like it would look better in the email.
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.
Since we do end up using the URL in the email body later I was thinking that we could do this:
The code before was using self._content.url into the email. so if we were invoking None, would it be the same as invoking an empty string?