-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Convert MessageBuilder.disable_errors to a context manager #10569
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
Changes from all commits
e2b7218
7147769
cb1ebcd
1aee326
6f72bb0
824b205
e86b3ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
from contextlib import contextmanager | ||
from typing import Iterator | ||
|
||
if sys.version_info < (3, 6): | ||
from collections import OrderedDict as OrderedDict # noqa: F401 | ||
else: | ||
# OrderedDict is kind of slow, so for most of our uses in Python 3.6 | ||
# and later we'd rather just use dict | ||
OrderedDict = dict | ||
|
||
|
||
if sys.version_info < (3, 7): | ||
@contextmanager | ||
def nullcontext() -> Iterator[None]: | ||
yield | ||
else: | ||
from contextlib import nullcontext as nullcontext # noqa: F401 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import sys | ||
from contextlib import contextmanager | ||
from typing import Iterator | ||
|
||
if sys.version_info < (3, 7): | ||
@contextmanager | ||
def nullcontext() -> Iterator[None]: | ||
yield | ||
else: | ||
from contextlib import nullcontext as nullcontext, contextmanager # noqa: F401 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: don't think you need to import contextmanager again. I think you could also move this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, copy-pasta, will fix. Re |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +0,0 @@ | ||
# OrderedDict is kind of slow, so for most of our uses in Python 3.6 | ||
# and later we'd rather just use dict | ||
|
||
import sys | ||
|
||
if sys.version_info < (3, 6): | ||
from collections import OrderedDict as OrderedDict | ||
else: | ||
OrderedDict = dict | ||
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.
Oops, the original comment added in #3666 got shifted around over the years.