-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
fix: changes a pylint check in dashboard module #10978
fix: changes a pylint check in dashboard module #10978
Conversation
- `disable=too-many-locals`, - `too-many-branches`, - `too-many-statements`
@willbarrett can you take a look? |
superset/databases/utils.py
Outdated
@@ -44,7 +44,7 @@ def get_indexes_metadata( | |||
def get_col_type(col: Dict[Any, Any]) -> str: | |||
try: | |||
dtype = f"{col['type']}" | |||
except Exception: # pylint: disable=broad-except | |||
except KeyError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think this one may be trickier. I was staring at this and wondering why a KeyError
is raised and on the exception handling we are trying to access the same key again with col["type"].__class__.__name__
. So the exception KeyError makes sense, because it may be possible, but what we are catching is a serialisation problem, # sqla.types.JSON __str__ has a bug, so using __class__.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dpgaspar for noticing this. Maybe I'm lacking the bigger picture here so excuse me if the question would be silly, but In that case why we are trying to do f"{col['type']}"
instead just having dtype = col["type"].__class__.__name__
without try catch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we want the default to be a call to sqla.type.__str__
and if that fails (on the comment it fails for sqla.types.JSON
) then use the class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, then I'm reverting this change
* master: (466 commits) chore: bump pandas to latest stable version (#11018) fix: dashboard edit button (again) (#11029) style(explore): use tertiary button against gray background (#11011) docs: add security vulnerability GH issue template (#11023) fix: [dashboard] should not show edit button when user has no edit permit (#11024) fix: timer component, fixes #10849, closes #11002 (#11004) fix: enable several pylint rules partially in db_engines_specs module (#11000) fix: pylint checks in connectors/sqla/models.py (#10974) fix: reenable pylint rule `unused-import` in charts and connectors modules (#11014) Enabled pylint rules in `db_engines` module: (#11016) fix: changes a pylint check in dashboard module (#10978) fix: menu shows a 0 when there are not settings (#11009) fix: query search low privileged user search access denied (#11017) chore: downgrade expected exception from error to info (#10994) fix: Add Item Overflow on Dataset Editor (#10983) Bring back import menu (#11007) feat(listview): feature flag config to set default viewing mode (#10986) build: add react-hooks linting (#11006) fix: unbreak ci (#11003) fix: enable pylint rules in db_engine_specs module (#10998) ... # Conflicts: # requirements.txt # superset/app.py # superset/models/schedules.py # superset/tasks/schedules.py # superset/translations/messages.pot
* Removed not needed disabled pylint rules from `set_dash_metadata`: - `disable=too-many-locals`, - `too-many-branches`, - `too-many-statements` * Changed broad exception to KeyError. * Reverted broad_exception in get_col_type in utils
SUMMARY
In
dao.py
file following rules doesn't have to be disabled:disable=too-many-locals
,too-many-branches
,too-many-statements
.Changed broad exception in
utils.py
toKeyError
.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
ADDITIONAL INFORMATION