Skip to content
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

style(mypy): Enforcing typing for views.database #9920

Conversation

john-bodley
Copy link
Member

SUMMARY

Adding mypy type enforcement for the superset.views.database module. Note because the superset.views module is quite large I opted to break the type enforcement into smaller more digestible chunks.

TEST PLAN

CI.

ADDITIONAL INFORMATION

  • 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

self, query, func
): # noqa pylint: disable=unused-argument,arguments-differ
def apply( # noqa pylint: disable=unused-argument
self, query: Query, value: Optional[Any]
Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed func to value for consistency with the base class.

self._pre_add_update(database)

def pre_delete(self, obj): # pylint: disable=no-self-use
if obj.tables:
def pre_delete(self, database: Database) -> None: # pylint: disable=no-self-use
Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed obj to database for consistency.

@codecov-commenter
Copy link

codecov-commenter commented May 26, 2020

Codecov Report

Merging #9920 into master will increase coverage by 0.00%.
The diff coverage is 97.50%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9920   +/-   ##
=======================================
  Coverage   71.31%   71.32%           
=======================================
  Files         585      585           
  Lines       30874    30876    +2     
  Branches     3236     3236           
=======================================
+ Hits        22019    22023    +4     
+ Misses       8746     8744    -2     
  Partials      109      109           
Flag Coverage Δ
#cypress 53.93% <ø> (+0.06%) ⬆️
#javascript 59.41% <ø> (ø)
#python 71.52% <97.50%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
superset/views/database/mixins.py 80.70% <87.50%> (+0.34%) ⬆️
superset/views/database/api.py 87.50% <100.00%> (+0.14%) ⬆️
superset/views/database/decorators.py 96.15% <100.00%> (+0.15%) ⬆️
superset/views/database/filters.py 100.00% <100.00%> (ø)
superset/views/database/forms.py 90.69% <100.00%> (-0.61%) ⬇️
superset/views/database/validators.py 84.21% <100.00%> (+0.87%) ⬆️
superset/views/database/views.py 89.74% <100.00%> (+0.26%) ⬆️
.../src/dashboard/components/gridComponents/Chart.jsx 88.76% <0.00%> (-1.13%) ⬇️
superset-frontend/src/SqlLab/actions/sqlLab.js 66.81% <0.00%> (ø)
...rontend/src/SqlLab/components/QueryAutoRefresh.jsx 72.72% <0.00%> (+6.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ce1076...8014f3a. Read the comment docs.

@john-bodley john-bodley force-pushed the john-bodley--mypy-enforcement-views-database branch from 28b8e5f to 529566d Compare May 28, 2020 03:29
@john-bodley john-bodley force-pushed the john-bodley--mypy-enforcement-views-database branch from 529566d to b6b2ed3 Compare May 28, 2020 03:35
@expose(
"/<int:pk>/table/<string:table_name>/<string:schema_name>/", methods=["GET"]
)
@expose("/<int:pk>/table/<table_name>/<schema_name>/", methods=["GET"])
Copy link
Member Author

Choose a reason for hiding this comment

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

Note per here string is the default converter type and thus doesn't need to be explicitly defined. This is consistent with other views.

@john-bodley john-bodley merged commit b010c35 into apache:master May 28, 2020
@john-bodley john-bodley deleted the john-bodley--mypy-enforcement-views-database branch May 28, 2020 04:04
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
Co-authored-by: John Bodley <john.bodley@airbnb.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants