Skip to content

Narrows some context manager scopes#2179

Merged
AndreMiras merged 1 commit intokivy:developfrom
AndreMiras:feature/narrow_context_manager
May 9, 2020
Merged

Narrows some context manager scopes#2179
AndreMiras merged 1 commit intokivy:developfrom
AndreMiras:feature/narrow_context_manager

Conversation

@AndreMiras
Copy link
Member

Tries to keep the current_directory context manager as scoped as
possible. Also use the contextlib.suppress context manager when
appropriated as it's more concise.

Tries to keep the `current_directory` context manager as scoped as
possible. Also use the `contextlib.suppress` context manager when
appropriated as it's more concise.
@AndreMiras AndreMiras requested a review from opacam May 8, 2020 22:01
Copy link
Member

@opacam opacam left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks 👍

Comment on lines -624 to -627
try:
with suppress(AttributeError):
constraints = constraints.decode("utf-8", "replace")
except AttributeError:
pass
Copy link
Member

Choose a reason for hiding this comment

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

🔥 two less lines of code without sacrificing readability 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I love that one :)
But it cannot really be used nicely if we have a large comment block above the pass, so yes I decided to introduced it only when we had a simple except ...: pass

@AndreMiras AndreMiras merged commit f96356b into kivy:develop May 9, 2020
@AndreMiras AndreMiras deleted the feature/narrow_context_manager branch May 9, 2020 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants