narrow: hoist a variable to a higher level to avoid use-before-init warning
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 20 Aug 2023 17:05:52 -0400
changeset 50882 75b90a8eb168
parent 50881 4803cea1e5ab
child 50883 9ed17632ad83
narrow: hoist a variable to a higher level to avoid use-before-init warning In practice, this shouldn't generate an IOError, so there wouldn't have been a problem. But PyCharm didn't know that.
hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py	Sun Aug 20 17:04:17 2023 -0400
+++ b/hgext/narrow/narrowcommands.py	Sun Aug 20 17:05:52 2023 -0400
@@ -527,8 +527,8 @@
     # import rules from a file
     newrules = opts.get('import_rules')
     if newrules:
+        filepath = os.path.join(encoding.getcwd(), newrules)
         try:
-            filepath = os.path.join(encoding.getcwd(), newrules)
             fdata = util.readfile(filepath)
         except IOError as inst:
             raise error.StorageError(