From 893fcd0debec6f7f09ef5b40f09e3c71f2b1aa50 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 21 May 2024 19:29:36 +0100 Subject: [PATCH] Resolve pylint possibly-used-before-assignment ************* Module fract4d.fractal fract4d/fractal.py:174:40: E0606: Possibly using variable 'main_file' before assignment (possibly-used-before-assignment) ************* Module fract4d.gradient fract4d/gradient.py:223:45: E0606: Possibly using variable 'factor' before assignment (possibly-used-before-assignment) ************* Module fract4d.tests.test_fract4d fract4d/tests/test_fract4d.py:582:36: E0606: Possibly using variable 'temp' before assignment (possibly-used-before-assignment) ************* Module fract4d_compiler.translate fract4d_compiler/translate.py:793:15: E0606: Possibly using variable 'r' before assignment (possibly-used-before-assignment) --- fract4d/fractal.py | 2 +- fract4d/gradient.py | 1 + fract4d/tests/test_fract4d.py | 1 + fract4d_compiler/translate.py | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fract4d/fractal.py b/fract4d/fractal.py index b0941b080..9c54bd969 100644 --- a/fract4d/fractal.py +++ b/fract4d/fractal.py @@ -171,7 +171,7 @@ def save(self, file, update_saved_flag=True, **kwds): if compress: file.close() - print(file.getvalue(), file=main_file) + print(file.getvalue(), file=main_file) # pylint: disable=possibly-used-before-assignment if update_saved_flag: self.saved = True diff --git a/fract4d/gradient.py b/fract4d/gradient.py index 8c68aef5e..51112eaa4 100644 --- a/fract4d/gradient.py +++ b/fract4d/gradient.py @@ -208,6 +208,7 @@ def get_color_at(self, pos): mpos = (self.mid - self.left) / len pos = (pos - self.left) / len + # pylint: disable=possibly-used-before-assignment if self.bmode == Blend.LINEAR: factor = self.get_linear_factor(pos, mpos) elif self.bmode == Blend.CURVED: diff --git a/fract4d/tests/test_fract4d.py b/fract4d/tests/test_fract4d.py index 2454468aa..e53b24a2f 100644 --- a/fract4d/tests/test_fract4d.py +++ b/fract4d/tests/test_fract4d.py @@ -572,6 +572,7 @@ def testFDSite(self): # we use a buffer here like in gtkfractal.py "onData" nb = 2 * 4 bytes = b"" + temp = b"" while True: # wait up to 1 sec until we can read, otherwise we assume the counterpart is gone (an error ocurred on the C++ layer) r, w, e = select.select([rfd], [], [], 1) diff --git a/fract4d_compiler/translate.py b/fract4d_compiler/translate.py index 11f30c9d0..36a967a85 100755 --- a/fract4d_compiler/translate.py +++ b/fract4d_compiler/translate.py @@ -771,6 +771,7 @@ def declarray(self, node): atype) def exp(self, node): + # pylint: disable=possibly-used-before-assignment if node.type == "const": r = self.const(node) elif node.type == "id":