Patchwork D1120: releasenotes: move import of fuzzywuzzy to import level

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 2:16 p.m.
Message ID <1bbdadfeb4cc10e823d0f70af186402d@localhost.localdomain>
Download mbox | patch
Permalink /patch/25100/
State Not Applicable
Headers show

Comments

phabricator - Oct. 17, 2017, 2:16 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbc2caa4b4480: releasenotes: move import of fuzzywuzzy to import level (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1120?vs=2831&id=2914

REVISION DETAIL
  https://phab.mercurial-scm.org/D1120

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, yuja
Cc: mercurial-devel

Patch

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -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