# HG changeset patch # User Matt Harbison # Date 1692565552 14400 # Node ID 75b90a8eb168e67dc31d75bf30a37014ca0c5c68 # Parent 4803cea1e5ab2614c3fc0728a0f3bcb65e144bdd 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. diff -r 4803cea1e5ab -r 75b90a8eb168 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(