Merge ~cjwatson/launchpad:importpedant-contextlib-exitstack into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 278cfc0a5a5713112353ff6b1a3fe22d36c62f8d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:importpedant-contextlib-exitstack
Merge into: launchpad:master
Diff against target: 13 lines (+2/-0)
1 file modified
lib/lp/scripts/utilities/importpedant.py (+2/-0)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+378600@code.launchpad.net

Commit message

Allow importing contextlib.ExitStack

Description of the change

This is only imported conditionally (on Python 2 we use contextlib2.ExitStack instead), but we need to mark it as valid anyway to stop the import pedant complaining.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
2index 7d7b268..83a62a8 100644
3--- a/lib/lp/scripts/utilities/importpedant.py
4+++ b/lib/lp/scripts/utilities/importpedant.py
5@@ -27,6 +27,8 @@ def text_lines_to_set(text):
6 # __all__. The following dict maps from such modules to a list of attributes
7 # that are allowed to be imported, whether or not they are in __all__.
8 valid_imports_not_in_all = {
9+ # Exported in Python 3, but missing and so not exported in Python 2.
10+ 'contextlib': set(['ExitStack']),
11 'cookielib': set(['domain_match']),
12 # Exported in Python 3, but missing and so not exported in Python 2.
13 'json.decoder': set(['JSONDecodeError']),

Subscribers

People subscribed via source and target branches

to status/vote changes: