Patchwork [STABLE] demandimport: explicitly declare `_session` at the module level

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 8, 2019, 9:06 a.m.
Message ID <c88fca729396738dafa2.1565255217@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41222/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 8, 2019, 9:06 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1565255173 -7200
#      Thu Aug 08 11:06:13 2019 +0200
# Branch stable
# Node ID c88fca729396738dafa233416d093e711bfb3532
# Parent  cba59b338976af0e4c92cf16b8f95331e6ac4f30
# EXP-Topic pyflakes-tracing
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c88fca729396
demandimport: explicitly declare `_session` at the module level

The `_session` module level variable is set within a function using the `global`
keyword. This confuse my `test-check-pyflakes.t`. Explicitly declaring the
variable at the top level solve the issue (and seems absolutely reasonable).
Yuya Nishihara - Aug. 8, 2019, 12:38 p.m.
On Thu, 08 Aug 2019 11:06:57 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1565255173 -7200
> #      Thu Aug 08 11:06:13 2019 +0200
> # Branch stable
> # Node ID c88fca729396738dafa233416d093e711bfb3532
> # Parent  cba59b338976af0e4c92cf16b8f95331e6ac4f30
> # EXP-Topic pyflakes-tracing
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c88fca729396
> demandimport: explicitly declare `_session` at the module level

Queued, thanks.

Patch

diff --git a/hgdemandimport/tracing.py b/hgdemandimport/tracing.py
--- a/hgdemandimport/tracing.py
+++ b/hgdemandimport/tracing.py
@@ -12,6 +12,7 @@  import os
 
 _pipe = None
 _checked = False
+_session = 'none'
 
 def _isactive():
     global _pipe, _session, _checked