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

Flake8 B904 #6356

Merged
merged 1 commit into from
Sep 5, 2024
Merged

Flake8 B904 #6356

merged 1 commit into from
Sep 5, 2024

Conversation

MetRonnie
Copy link
Member

No description provided.

@MetRonnie MetRonnie self-assigned this Sep 4, 2024
@MetRonnie MetRonnie requested a review from wxtim September 4, 2024 12:21
@MetRonnie MetRonnie added the small label Sep 4, 2024
@MetRonnie MetRonnie added this to the 8.4.0 milestone Sep 4, 2024
Comment on lines 380 to +381
except KeyError:
raise InputError(f'No such task state "{selector}"')
raise InputError(f'No such task state "{selector}"') from None
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity why this and not:

except KeyError as keyerr:
    raise InputError('Message') from keyerr

Should not block approval or merging.

Copy link
Member Author

Choose a reason for hiding this comment

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

https://docs.python.org/3/tutorial/errors.html#exception-chaining

KeyError is the type of error that will never have any useful information to the user, so there is no point including it in the traceback, it would just be noise

from exc:

KeyError                                  Traceback (most recent call last)
Cell In[3], line 2
      1 try:
----> 2     dict_['x']
      3 except KeyError as exc:

KeyError: 'x'

The above exception was the direct cause of the following exception:

UsefulError                               Traceback (most recent call last)
Cell In[3], line 4
      2     dict_['x']
      3 except KeyError as exc:
----> 4     raise UsefulError('Oopsie') from exc

UsefulError: Oopsie

vs from None:

UsefulError                               Traceback (most recent call last)
Cell In[4], line 4
      2     dict_['y']
      3 except KeyError:
----> 4     raise UsefulError('Oopsie') from None

UsefulError: Oopsie

vs no from at all:

KeyError                                  Traceback (most recent call last)
Cell In[5], line 2
      1 try:
----> 2     dict_['z']
      3 except KeyError:

KeyError: 'z'

During handling of the above exception, another exception occurred:

UsefulError                               Traceback (most recent call last)
Cell In[5], line 4
      2     dict_['z']
      3 except KeyError:
----> 4     raise UsefulError('Oopsie')

UsefulError: Oopsie

Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

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

1 Comment for my learning: Feel free to merge.

@MetRonnie MetRonnie merged commit 293c3cc into cylc:master Sep 5, 2024
16 of 27 checks passed
@MetRonnie MetRonnie deleted the flake8 branch September 5, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants