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 2019/08/12 23:19:43 UTC

[GitHub] [incubator-superset] john-bodley opened a new pull request #8034: [viz] Adding get_def typing

john-bodley opened a new pull request #8034: [viz] Adding get_def typing
URL: https://github.com/apache/incubator-superset/pull/8034
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [x] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   
   I came across a bug in `viz.py` where [`get_csv`](https://github.com/apache/incubator-superset/blob/8cd8ec16d5017076b639a76514069cc276f930ad/superset/viz.py#L489) which uses logic like, 
   
   ```
   def get_csv(self):
       df = self.get_df()
       include_index = not isinstance(df.index, pd.RangeIndex)
       ...
   ```
   
   i.e., it assumes that `df` is of type `pd.DataFrame` whereas it can optionally be `None`. Going forward I'm not sure what the correct logic should be but I've added basic type hints to the `get_df(...)` method to inform developers that it can be either a `pd.DataFrame` or `None`. 
   
   Note my preference would be for `get_df(...)` to only return a `pd.DataFrame`, that way we wouldn't need to write logic like `if df is None` in numerous places. One question is if `df` is `None` should the return value from `get_csv()` be `None` or should it be a serialized empty `pd.DataFrame`?
   
   ### 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: @etr2460 @mistercrunch @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