You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/03/29 02:16:41 UTC

[GitHub] [incubator-superset] john-bodley opened a new pull request #9411: [mypy] Enforcing typing for charts

john-bodley opened a new pull request #9411: [mypy] Enforcing typing for charts
URL: https://github.com/apache/incubator-superset/pull/9411
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [x] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   
   We've all learnt over the past few weeks the value of containment. Trying to piecemeal enforce `mypy` typing and thus trying this one root level folder at a time.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TEST PLAN
   
   CI.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ### REVIEWERS
   
   to: @dpgaspar @etr2460 @serenajiang  @villebro 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] dpgaspar commented on issue #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on issue #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#issuecomment-605702645
 
 
   I will, thks!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] john-bodley commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
john-bodley commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399842193
 
 

 ##########
 File path: superset/views/base.py
 ##########
 @@ -392,7 +393,7 @@ def check_ownership(obj, raise_if_false=True):
     orig_obj = scoped_session.query(obj.__class__).filter_by(id=obj.id).first()
 
     # Making a list of owners that works across ORM models
-    owners = []
+    owners: User = []
 
 Review comment:
   BTW the reasons these issues didn't fire is merely because the enforcement is on the `superset.charts` module. It simply requires the return types for calls to be defined.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] john-bodley commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
john-bodley commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399842193
 
 

 ##########
 File path: superset/views/base.py
 ##########
 @@ -392,7 +393,7 @@ def check_ownership(obj, raise_if_false=True):
     orig_obj = scoped_session.query(obj.__class__).filter_by(id=obj.id).first()
 
     # Making a list of owners that works across ORM models
-    owners = []
+    owners: User = []
 
 Review comment:
   BTW the reasons these issues didn't fire is merely because the enforcement is on the `superset.charts` module. It simply requires the calls to be typed.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399833505
 
 

 ##########
 File path: superset/utils/core.py
 ##########
 @@ -547,7 +547,7 @@ def get_datasource_full_name(database_name, datasource_name, schema=None):
     return "[{}].[{}].[{}]".format(database_name, schema, datasource_name)
 
 
-def validate_json(obj):
+def validate_json(obj: Union[bytes, bytearray, str]) -> None:
 
 Review comment:
   Is this the best practice in the absence of a proper `from typing import JSONType`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] codecov-io edited a comment on issue #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#issuecomment-605551253
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=h1) Report
   > Merging [#9411](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/e63cb52630915698a69633bd222c44a4b375bb21&el=desc) will **not change** coverage by `%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-superset/pull/9411/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l)](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #9411   +/-   ##
   =======================================
     Coverage   59.01%   59.01%           
   =======================================
     Files         378      378           
     Lines       12162    12162           
     Branches     3004     3004           
   =======================================
     Hits         7177     7177           
     Misses       4805     4805           
     Partials      180      180           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=footer). Last update [e63cb52...f38de53](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399832298
 
 

 ##########
 File path: superset/charts/dao.py
 ##########
 @@ -32,13 +32,14 @@ class ChartDAO(BaseDAO):
     base_filter = ChartFilter
 
     @staticmethod
-    def bulk_delete(models: List[Slice], commit=True):
-        item_ids = [model.id for model in models]
+    def bulk_delete(models: Optional[List[Slice]], commit: bool = True) -> None:
+        item_ids = [model.id for model in models] if models else []
 
 Review comment:
   Nice catch 👍 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399835630
 
 

 ##########
 File path: superset/dao/base.py
 ##########
 @@ -75,7 +75,7 @@ def find_by_ids(cls, model_ids: List[int]) -> List[Model]:
         return query.all()
 
     @classmethod
-    def create(cls, properties: Dict, commit=True) -> Optional[Model]:
+    def create(cls, properties: Dict, commit=True) -> Model:
 
 Review comment:
   A bit redundant but since `check_ownership` also adds `bool` for the named parameter:
   `def create(cls, properties: Dict, commit: bool = True) -> Model:`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] codecov-io commented on issue #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#issuecomment-605551253
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=h1) Report
   > Merging [#9411](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/e63cb52630915698a69633bd222c44a4b375bb21&el=desc) will **not change** coverage by `%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-superset/pull/9411/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l)](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #9411   +/-   ##
   =======================================
     Coverage   59.01%   59.01%           
   =======================================
     Files         378      378           
     Lines       12162    12162           
     Branches     3004     3004           
   =======================================
     Hits         7177     7177           
     Misses       4805     4805           
     Partials      180      180           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=footer). Last update [e63cb52...38bcb0c](https://codecov.io/gh/apache/incubator-superset/pull/9411?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] john-bodley commented on issue #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
john-bodley commented on issue #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#issuecomment-605687638
 
 
   @villebro @dpgaspar for context I'm going to tackle `utils` and a few others. It seems like @dpgaspar will try to tackle `dashboards` and `datasets`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399833505
 
 

 ##########
 File path: superset/utils/core.py
 ##########
 @@ -547,7 +547,7 @@ def get_datasource_full_name(database_name, datasource_name, schema=None):
     return "[{}].[{}].[{}]".format(database_name, schema, datasource_name)
 
 
-def validate_json(obj):
+def validate_json(obj: Union[bytes, bytearray, str]) -> None:
 
 Review comment:
   Is this the best practice in the absence of a proper `from typing import JSONType`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] john-bodley merged pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
john-bodley merged pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399835722
 
 

 ##########
 File path: superset/dao/base.py
 ##########
 @@ -95,7 +95,7 @@ def create(cls, properties: Dict, commit=True) -> Optional[Model]:
         return model
 
     @classmethod
-    def update(cls, model: Model, properties: Dict, commit=True) -> Optional[Model]:
+    def update(cls, model: Model, properties: Dict, commit=True) -> Model:
 
 Review comment:
   Same here?
   `def update(cls, model: Model, propertied: Dict, commit: bool = True) -> Model:`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #9411: [mypy] Enforcing typing for superset.charts
URL: https://github.com/apache/incubator-superset/pull/9411#discussion_r399835098
 
 

 ##########
 File path: superset/views/base.py
 ##########
 @@ -392,7 +393,7 @@ def check_ownership(obj, raise_if_false=True):
     orig_obj = scoped_session.query(obj.__class__).filter_by(id=obj.id).first()
 
     # Making a list of owners that works across ORM models
-    owners = []
+    owners: User = []
 
 Review comment:
   Should this be `List[User]` ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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