XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/197444

Change subject: [IMPROV] config2: Automatically list imports
......................................................................

[IMPROV] config2: Automatically list imports

Instead of having to remember adding the imports manually in a tuple
this automatically iterates over the global variables and generates the
list (technically a frozenset) from there.

Change-Id: Iaeea9e6e5579153d0211b7625eec607ba65b8748
---
M pywikibot/config2.py
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/44/197444/1

diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 5169b0c..8a1d64d 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -29,16 +29,18 @@
 
 from warnings import warn
 
+# This frozen set should contain all imported modules/variables, so it should
+# occur directly after the imports. At that point globals() only contains the
+# names and some magic variables (like __name__)
+_imported_modules = frozenset(name for name in globals()
+                              if not name.startswith('_'))
+
 
 class _ConfigurationDeprecationWarning(UserWarning):
 
     """Feature that is no longer supported."""
 
     pass
-
-
-# Please keep _imported_modules in sync with the imports above
-_imported_modules = ('collections', 'os', 'stat', 'sys')
 
 # IMPORTANT:
 # Do not change any of the variables in this file. Instead, make

-- 
To view, visit https://gerrit.wikimedia.org/r/197444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaeea9e6e5579153d0211b7625eec607ba65b8748
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to