scikit-hep / scikit-hep/vector

Possibly used before assignment pylint warning

Open
#512 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue hacktoberfest
Dominant language
Python
Stars
99
Forks
42
Avg merge
1d 13h
Merged PRs (30d)
6

Description

Vector Version

main

Python Version

Pylint

OS / Environment

Any

Describe the bug

This report is showing potentially problematic code:

************* Module vector.backends._numba_object
src/vector/backends/_numba_object.py:1502:12: E0606: Possibly using variable 'signature' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1510:31: E0606: Possibly using variable 'coord11' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1510:44: E0606: Possibly using variable 'coord12' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1510:57: E0606: Possibly using variable 'coord21' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1510:70: E0606: Possibly using variable 'coord22' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1520:24: E0601: Using variable 'coord13' before assignment (used-before-assignment)
src/vector/backends/_numba_object.py:1523:24: E0601: Using variable 'coord23' before assignment (used-before-assignment)
src/vector/backends/_numba_object.py:1534:24: E0601: Using variable 'coord14' before assignment (used-before-assignment)
src/vector/backends/_numba_object.py:1538:24: E0601: Using variable 'coord24' before assignment (used-before-assignment)
src/vector/backends/_numba_object.py:1663:12: E0606: Possibly using variable 'groupname' before assignment (possibly-used-before-assignment)
src/vector/backends/_numba_object.py:1665:12: E0606: Possibly using variable 'signature' before assignment (possibly-used-before-assignment)
************* Module vector.backends.numpy
src/vector/backends/numpy.py:190:19: E0606: Possibly using variable 'generic' before assignment (possibly-used-before-assignment)
src/vector/backends/numpy.py:369:28: E0606: Possibly using variable 'thisshape' before assignment (possibly-used-before-assignment)
************* Module vector._compute.lorentz.equal
src/vector/_compute/lorentz/equal.py:128:16: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/equal.py:129:19: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.add
src/vector/_compute/lorentz/add.py:121:17: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/add.py:122:17: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
src/vector/_compute/lorentz/add.py:157:16: E0601: Using variable 'to_tau' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.subtract
src/vector/_compute/lorentz/subtract.py:121:17: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/subtract.py:122:17: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
src/vector/_compute/lorentz/subtract.py:157:16: E0601: Using variable 'to_tau' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.isclose
src/vector/_compute/lorentz/isclose.py:161:16: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/isclose.py:162:16: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.boost_p4
src/vector/_compute/lorentz/boost_p4.py:735:16: E0606: Possibly using variable 'to_x' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/boost_p4.py:736:16: E0606: Possibly using variable 'to_y' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/boost_p4.py:737:16: E0601: Using variable 'to_z' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.boost_beta3
src/vector/_compute/lorentz/boost_beta3.py:349:16: E0606: Possibly using variable 'to_x' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/boost_beta3.py:350:16: E0606: Possibly using variable 'to_y' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/boost_beta3.py:351:16: E0601: Using variable 'to_z' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.dot
src/vector/_compute/lorentz/dot.py:115:12: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/dot.py:116:14: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.transform4D
src/vector/_compute/lorentz/transform4D.py:158:16: E0606: Possibly using variable 'to_x' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/transform4D.py:159:16: E0606: Possibly using variable 'to_y' before assignment (possibly-used-before-assignment)
src/vector/_compute/lorentz/transform4D.py:160:16: E0601: Using variable 'to_z' before assignment (used-before-assignment)
src/vector/_compute/lorentz/transform4D.py:161:16: E0601: Using variable 'to_t' before assignment (used-before-assignment)
************* Module vector._compute.lorentz.not_equal
src/vector/_compute/lorentz/not_equal.py:128:16: E0601: Using variable 'to_t1' before assignment (used-before-assignment)
src/vector/_compute/lorentz/not_equal.py:129:19: E0601: Using variable 'to_t2' before assignment (used-before-assignment)
************* Module vector._compute.spatial.cross
src/vector/_compute/spatial/cross.py:104:16: E0606: Possibly using variable 'to_x1' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/cross.py:105:16: E0606: Possibly using variable 'to_y1' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/cross.py:106:16: E0601: Using variable 'to_z1' before assignment (used-before-assignment)
src/vector/_compute/spatial/cross.py:107:16: E0606: Possibly using variable 'to_x2' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/cross.py:108:16: E0606: Possibly using variable 'to_y2' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/cross.py:109:16: E0601: Using variable 'to_z2' before assignment (used-before-assignment)
************* Module vector._compute.spatial.rotate_axis
src/vector/_compute/spatial/rotate_axis.py:123:16: E0606: Possibly using variable 'to_x1' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_axis.py:124:16: E0606: Possibly using variable 'to_y1' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_axis.py:125:16: E0601: Using variable 'to_z1' before assignment (used-before-assignment)
src/vector/_compute/spatial/rotate_axis.py:126:16: E0606: Possibly using variable 'to_x2' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_axis.py:127:16: E0606: Possibly using variable 'to_y2' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_axis.py:128:16: E0601: Using variable 'to_z2' before assignment (used-before-assignment)
************* Module vector._compute.spatial.rotate_euler
src/vector/_compute/spatial/rotate_euler.py:248:16: E0606: Possibly using variable 'to_x' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_euler.py:249:16: E0606: Possibly using variable 'to_y' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_euler.py:250:16: E0601: Using variable 'to_z' before assignment (used-before-assignment)
************* Module vector._compute.spatial.rotate_quaternion
src/vector/_compute/spatial/rotate_quaternion.py:95:16: E0606: Possibly using variable 'to_x' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_quaternion.py:96:16: E0606: Possibly using variable 'to_y' before assignment (possibly-used-before-assignment)
src/vector/_compute/spatial/rotate_quaternion.py:97:16: E0601: Using variable 'to_z' before assignment (used-before-assignment)

We should add assert statements at least to give nice errors on the branches where used-later variables are unset.

I've ignored the new check for now in #511.

Any additional but relevant log output

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Pylint output, then inspect the reported branches in src/vector/backends/_numba_object.py, src/vector/backends/numpy.py, and the listed files under src/vector/_compute/. Add assertions where later-used variables can remain unset, and rerun Pylint to confirm the reported warnings are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.