changeset 34812:bc2caa4b4480

releasenotes: move import of fuzzywuzzy to import level This will help us in determining easily that whether fuzzywuzzy is loaded or not loaded in any of the function. Differential Revision: https://phab.mercurial-scm.org/D1120
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 16 Oct 2017 22:46:11 +0530
parents a542ad320adb
children 288fad8c55f9
files hgext/releasenotes.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/releasenotes.py	Sun Oct 15 20:31:44 2017 +0530
+++ b/hgext/releasenotes.py	Mon Oct 16 22:46:11 2017 +0530
@@ -33,6 +33,12 @@
 cmdtable = {}
 command = registrar.command(cmdtable)
 
+try:
+    import fuzzywuzzy.fuzz as fuzz
+    fuzz.token_set_ratio
+except ImportError:
+    fuzz = None
+
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
@@ -219,10 +225,8 @@
     """
     Returns false when note fragment can be merged to existing notes.
     """
-    try:
-        import fuzzywuzzy.fuzz as fuzz
-        fuzz.token_set_ratio
-    except ImportError:
+    # fuzzywuzzy not present
+    if not fuzz:
         return True
 
     merge = True