Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint fails with errors about bad-option-value #6691

Open
mhucka opened this issue Jul 31, 2024 · 4 comments
Open

pylint fails with errors about bad-option-value #6691

mhucka opened this issue Jul 31, 2024 · 4 comments
Assignees
Labels
kind/docs Documentation related problems, ideas, requests triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@mhucka
Copy link
Contributor

mhucka commented Jul 31, 2024

Description of the issue

After a fresh installation of Cirq 1.4.1, running the command

pylint --rcfile=dev_tools/conf/.pylintrc cirq

(as described in the dev docs) leads to many errors like this:

************* Module cirq._version_test
cirq-core/cirq/_version_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)

This happens with pylint version 2.13.9, which is the version installed from dev_tools/requirements/deps/pylint.txt.

How to reproduce the issue

I installed Cirq 1.4.1 by cloning the main branch of the GitHub repo, then did the following to get the release tagged with 1.4.1 into a local branch:

git checkout v1.4.1 -b testing-1.4.1

Then I followed the instructions in "Setting up an environment", modifying them slightly for my MacOS 13.6.7 environment running Python version 3.10.10. I did the virtualenv installation,

mkvirtualenv cirq-py3
workon cirq-py3
pip install --upgrade pip    
pip install -r dev_tools/requirements/dev.env.txt

I ran ./check/pytest . to make sure things looked reasonable; this produced an error involving sympy (which I'm currently investigating) but no other errors, and IMHO, nothing that looked relevant to the particular mypy error being reported in this issue. Then did the following, per instructions:

source dev_tools/pypath

Then I tried running the 3 steps in the section "Continuous integration and local testing". The step for pylint resulted in the following output.

************* Module cirq._version_test
cirq-core/cirq/_version_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.value.product_state_test
cirq-core/cirq/value/product_state_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.json_test
cirq-core/cirq/contrib/json_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.json
cirq-core/cirq/contrib/json.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.svg.svg_test
cirq-core/cirq/contrib/svg/svg_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.svg.__init__
cirq-core/cirq/contrib/svg/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.svg.svg
cirq-core/cirq/contrib/svg/svg.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.state_vector_test
cirq-core/cirq/contrib/quimb/state_vector_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.mps_simulator_test
cirq-core/cirq/contrib/quimb/mps_simulator_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.__init__
cirq-core/cirq/contrib/quimb/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.grid_circuits_test
cirq-core/cirq/contrib/quimb/grid_circuits_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.state_vector
cirq-core/cirq/contrib/quimb/state_vector.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.density_matrix_test
cirq-core/cirq/contrib/quimb/density_matrix_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quimb.density_matrix
cirq-core/cirq/contrib/quimb/density_matrix.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quantum_volume.quantum_volume_test
cirq-core/cirq/contrib/quantum_volume/quantum_volume_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.contrib.quantum_volume.quantum_volume
cirq-core/cirq/contrib/quantum_volume/quantum_volume.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.__init__
cirq-core/cirq/testing/_compat_test_data/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.repeated.cirq.testing._compat_test_data.repeated_child.child.__init__
cirq-core/cirq/testing/_compat_test_data/repeated/cirq/testing/_compat_test_data/repeated_child/child/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.types
cirq-core/cirq/testing/_compat_test_data/module_a/types.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.module_b.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/module_b/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.module_b.module_c.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/module_b/module_c/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.sub.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/sub/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.sub.subsub.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.sub.subsub.dupe
cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/dupe.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.testing._compat_test_data.module_a.dupe.__init__
cirq-core/cirq/testing/_compat_test_data/module_a/dupe/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.transformers.heuristic_decompositions.gate_tabulation_math_utils
cirq-core/cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.transformers.heuristic_decompositions.gate_tabulation_math_utils_test
cirq-core/cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.work.observable_readout_calibration_test
cirq-core/cirq/work/observable_readout_calibration_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.work.observable_readout_calibration
cirq-core/cirq/work/observable_readout_calibration.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.projector_test
cirq-core/cirq/ops/projector_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.kraus_channel
cirq-core/cirq/ops/kraus_channel.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.projector
cirq-core/cirq/ops/projector.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.kraus_channel_test
cirq-core/cirq/ops/kraus_channel_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.mixed_unitary_channel_test
cirq-core/cirq/ops/mixed_unitary_channel_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.mixed_unitary_channel
cirq-core/cirq/ops/mixed_unitary_channel.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.ops.phased_x_z_gate_test
cirq-core/cirq/ops/phased_x_z_gate_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.sim.clifford.__init__
cirq-core/cirq/sim/clifford/__init__.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.sim.clifford.clifford_simulator_test
cirq-core/cirq/sim/clifford/clifford_simulator_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)
************* Module cirq.devices.device_test
cirq-core/cirq/devices/device_test.py:1:0: E0012: Bad option value 'wrong-or-nonexistent-copyright-notice' (bad-option-value)

The problem appears to be due to line 58 in dev_tools/conf/.pylintrc. There seems to be no pylint option named wrong-or-nonexistent-copyright-notice.

Cirq version

> pwd
/Users/mhucka/project-files/google/repos/cirq-testing/Cirq
> grep __version__ cirq-core/cirq/_version.py
__version__ = "1.4.1"
> pylint --version
pylint 2.13.9
astroid 2.11.7
Python 3.10.10 (main, Apr  2 2023, 09:03:06) [Clang 14.0.3 (clang-1403.0.22.14.1)]
> python --version
Python 3.10.10
> sw_vers
ProductName:		macOS
ProductVersion:		13.6.7
BuildVersion:		22G720
@mhucka mhucka added the kind/bug-report Something doesn't seem to work. label Jul 31, 2024
@mhucka
Copy link
Contributor Author

mhucka commented Jul 31, 2024

Investigating further, I came across old issue #4564 and PR #4577, which added a pylint module to implement wrong-or-nonexistent-copyright-notice in dev_tools/pylint_copyright_checker.py. Evidently, this is supposed to be loaded by the second line in dev_tools/conf/.pylintrc. I don't know why that's not happening in my environment. The command I ran,

pylint --rcfile=dev_tools/conf/.pylintrc cirq

explicitly uses the .pylintrc file.

@NoureldinYosri NoureldinYosri added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Jul 31, 2024
@senecameeks senecameeks added kind/docs Documentation related problems, ideas, requests triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque kind/bug-report Something doesn't seem to work. labels Jul 31, 2024
@senecameeks
Copy link
Collaborator

senecameeks commented Jul 31, 2024

Cirq Cync: likely not a bug in code but an issue in outdated documentation. Suggest fix: update documentation to say run check/pylint instead of check/pytest. And update documentation remove references to directories that no longer exist.

@mhucka
Copy link
Contributor Author

mhucka commented Aug 2, 2024

Just confirming that running ./check/pylint indeed doesn't produce the error I originally reported. My confusion arose because I was going a bit too quickly through the dev docs section on local testing and blindly followed the suggestion near the top,

The text implies that one could run pylint directly as an alternative to ./check/pylint.

I think it's not impossible that other people might run into the same problem when reading that page. To help avoid that, two alternatives come to mind:

  1. One option is to change the documentation to remove the example of "simple" commands for pylint etc., and simply go directly to telling people to use ./check/pylint.
  2. Make it possible to run pylint directly after all. Inspecting the check/pylint script, we see that how it enables pylint to find dev_tools/pylint_copyright_checker.py is by adding the dev_tools directory to the $PYTHONPATH environment variable before invoking pylint. The effect can be also be accomplished by modifying the .pylintrc file.

I will open a PR for alternative 2 so people can evaluate that idea.

@mhucka mhucka self-assigned this Aug 21, 2024
@mhucka
Copy link
Contributor Author

mhucka commented Sep 4, 2024

Noting another issue discussed in today's cirq cynq: we're currently running an older version of pylint because the API changed. We should also review what it would take to update the version of pylint being used. Updating the version of pylint may change what needs to be done for copyright checks.

See issue #6351.

This means that the first order of business is to revisit #6531 and see what would be required to update the version of pylint used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/docs Documentation related problems, ideas, requests triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

No branches or pull requests

3 participants