You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sebastianliebscher (via GitHub)" <gi...@apache.org> on 2023/11/10 13:54:57 UTC

[PR] chore: Simplify views/base [superset]

sebastianliebscher opened a new pull request, #25948:
URL: https://github.com/apache/superset/pull/25948

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   Simplifies views/base.py to make code more readable / maintainable by using 
   - X | Y type hints ([PEP 604](https://peps.python.org/pep-0604/))
   - dict comprehension instead of for loop
   - removed unused function parameters
   
   
   ### TESTING INSTRUCTIONS
   - local unit / integration tests + GitHub CI
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley merged PR #25948:
URL: https://github.com/apache/superset/pull/25948


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1389793257


##########
superset/views/base.py:
##########
@@ -139,15 +141,11 @@ def get_error_msg() -> str:
 
 
 def json_error_response(
-    msg: Optional[str] = None,
+    msg: str | None = None,
     status: int = 500,
-    payload: Optional[dict[str, Any]] = None,
-    link: Optional[str] = None,

Review Comment:
   @sebastianliebscher it seems like the `payload` argument isn't use in the codebase either.



##########
superset/views/base.py:
##########
@@ -682,18 +674,14 @@ def apply(self, query: Query, value: Any) -> Query:
 
 
 class CsvResponse(Response):
-    """
-    Override Response to take into account csv encoding from config.py
-    """
+    """Override Response to take into account csv encoding from config.py"""

Review Comment:
   Were these comments manually or automatically changed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1390173946


##########
superset/views/base.py:
##########
@@ -682,18 +674,14 @@ def apply(self, query: Query, value: Any) -> Query:
 
 
 class CsvResponse(Response):
-    """
-    Override Response to take into account csv encoding from config.py
-    """
+    """Override Response to take into account csv encoding from config.py"""

Review Comment:
   @sebastianliebscher could you please revert these docstring changes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1390174777


##########
superset/views/base.py:
##########
@@ -682,18 +674,14 @@ def apply(self, query: Query, value: Any) -> Query:
 
 
 class CsvResponse(Response):
-    """
-    Override Response to take into account csv encoding from config.py
-    """
+    """Override Response to take into account csv encoding from config.py"""

Review Comment:
   @john-bodley Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1389427641


##########
superset/views/base.py:
##########
@@ -192,15 +189,15 @@ def generate_download_headers(
 
 def deprecated(
     eol_version: str = "4.0.0",
-    new_target: Optional[str] = None,
+    new_target: str | None = None,
 ) -> Callable[[Callable[..., FlaskResponse]], Callable[..., FlaskResponse]]:
     """
     A decorator to set an API endpoint from SupersetView has deprecated.
     Issues a log warning
     """
 
     def _deprecated(f: Callable[..., FlaskResponse]) -> Callable[..., FlaskResponse]:
-        def wraps(self: "BaseSupersetView", *args: Any, **kwargs: Any) -> FlaskResponse:

Review Comment:
   this was auto-changed by pre-commit `pyupgrade` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1389426613


##########
superset/views/base.py:
##########
@@ -139,15 +141,11 @@ def get_error_msg() -> str:
 
 
 def json_error_response(
-    msg: Optional[str] = None,
+    msg: str | None = None,
     status: int = 500,
-    payload: Optional[dict[str, Any]] = None,
-    link: Optional[str] = None,

Review Comment:
   `link` parameter is not used in the codebase at all



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1390160525


##########
superset/views/base.py:
##########
@@ -139,15 +141,11 @@ def get_error_msg() -> str:
 
 
 def json_error_response(
-    msg: Optional[str] = None,
+    msg: str | None = None,
     status: int = 500,
-    payload: Optional[dict[str, Any]] = None,
-    link: Optional[str] = None,

Review Comment:
   there is a single usage here https://github.com/apache/superset/blob/d95c200e6931e2bc14b0448e3da265d8ebedf249/superset/views/core.py#L166



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on code in PR #25948:
URL: https://github.com/apache/superset/pull/25948#discussion_r1390160637


##########
superset/views/base.py:
##########
@@ -682,18 +674,14 @@ def apply(self, query: Query, value: Any) -> Query:
 
 
 class CsvResponse(Response):
-    """
-    Override Response to take into account csv encoding from config.py
-    """
+    """Override Response to take into account csv encoding from config.py"""

Review Comment:
   Manually. If that change is not desired, I'll revert it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Simplify views/base [superset]

Posted by "sebastianliebscher (via GitHub)" <gi...@apache.org>.
sebastianliebscher commented on PR #25948:
URL: https://github.com/apache/superset/pull/25948#issuecomment-1806773822

   The test that is failing is unrelated. There is another PR to address this https://github.com/apache/superset/pull/25958


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org