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

chore: harmonize python enum naming conventions #26948

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

villebro
Copy link
Member

@villebro villebro commented Feb 1, 2024

SUMMARY

This is a continuation of #26875, and refactors all Python enums to comply with the commonly used naming conventions of PascalCase for the class name, and UPPER_CASE for the names: https://docs.python.org/3/library/enum.html This exercise was quite a bit less painful than on the frontend. 😸

Unfortunately I'm not aware of anything that would come close to ESLint for Python, so for now we'll just have to try to make sure everyone adheres to these conventions during code review. I believe something similar might be possible with pylint, but I wasn't able to scope it to only apply to enums, so I'll just leave it be. But if someone knows how this can be done, or can point me in the right direction, please do let me know.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@villebro villebro requested a review from a team as a code owner February 1, 2024 05:10
@github-actions github-actions bot added the risk:db-migration PRs that require a DB migration label Feb 1, 2024
@villebro villebro removed the risk:db-migration PRs that require a DB migration label Feb 1, 2024
Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

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

@villebro it would be great if pylint could prevent any future regressions. Per pylint-dev/pylint#3896 it seems like this functionality exists, so I'm a little perplexed as to why it's not working.

@villebro
Copy link
Member Author

villebro commented Feb 1, 2024

Thanks for the pointing me in the right direction @john-bodley! I agree, this seems to be covered by vanilla pylint already. Let me try to figure out why this isn't being checked correctly..

@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 1, 2024
@github-actions github-actions bot added the risk:db-migration PRs that require a DB migration label Feb 1, 2024
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: Patch coverage is 56.52174% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 59.66%. Comparing base (a09e555) to head (0c9978d).
Report is 197 commits behind head on master.

Files Patch % Lines
superset/tags/models.py 66.66% 4 Missing ⚠️
superset/common/tags.py 0.00% 3 Missing ⚠️
superset/tags/filters.py 0.00% 2 Missing ⚠️
superset/daos/tag.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26948      +/-   ##
==========================================
- Coverage   69.50%   59.66%   -9.85%     
==========================================
  Files        1900     1899       -1     
  Lines       74347    73976     -371     
  Branches     8264     8041     -223     
==========================================
- Hits        51677    44138    -7539     
- Misses      20621    27869    +7248     
+ Partials     2049     1969      -80     
Flag Coverage Δ
hive 53.81% <39.13%> (ø)
mysql ?
postgres ?
presto 53.76% <39.13%> (ø)
python 62.51% <56.52%> (-20.52%) ⬇️
sqlite ?
unit 56.43% <56.52%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

object_id=1, object_type=ObjectType.dashboard.name, tag_id=tag.id
object_id=1, object_type=ObjectType.DASHBOARD, tag_id=tag.id
Copy link
Member Author

Choose a reason for hiding this comment

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

@john-bodley the fact that my IDE was able to identify these type errors indicates that our /tests/ directory is in need of some serious linting love. I think the time has come to enable full linting on our Python test suites. WDYT? I can't remember how many bycatch unused imports I've removed over the last few years. I can probably start by cleaning up the unit test suite, as that seems to be the simplest place to start..

Copy link
Member

Choose a reason for hiding this comment

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

@villebro I’ve been making some rather XXL refactors recently and wished that we had mypy and pylint checks for the entirety of the Python code base including tests and migrations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've found mypy can be very temperamental, but mostly that's in terms of checking far beyond the scope of what it's being asked to in the first place. It does do a good job of catching problems when it's not a false positive though. pylint is much less temperamental so at least having that seems a no-brainer.

@villebro villebro removed the risk:db-migration PRs that require a DB migration label Feb 1, 2024
@github-actions github-actions bot added the risk:db-migration PRs that require a DB migration label Feb 1, 2024
@villebro villebro removed the risk:db-migration PRs that require a DB migration label Feb 1, 2024
@villebro
Copy link
Member Author

villebro commented Feb 1, 2024

image

image

@michael-s-molina michael-s-molina added the v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch label Feb 1, 2024
@villebro
Copy link
Member Author

villebro commented Feb 1, 2024

This turned ugly, just as I suspected 🤦 Link to a Slack thread that I opened to get some feedback: https://apache-superset.slack.com/archives/CCKHMGRRB/p1706829726367459?thread_ts=1706828839.332729&cid=CCKHMGRRB

@michael-s-molina michael-s-molina added v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch and removed v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch labels Feb 23, 2024
@michael-s-molina michael-s-molina added v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch and removed v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch labels Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants