-
Notifications
You must be signed in to change notification settings - Fork 1k
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 checker for copyright notices #4564
Comments
A 'raw checker' should be able to check it. Can you assign the task to me? |
@yjt98765 Assigned. |
Here's a tool I've seen used in other projects for a similar purpose: https://github.com/fsfe/reuse-tool |
Thanks for the recommendation @ronnie-llamado . We prefer to leverage tools we already have like pylint for these cases because Cirq contains too many dependencies as it is. |
Thank you! As shown in this example, we need to assign an id (a letter + 4 digits) to the message. Since no custom checkers have been used in this project, we should come up with a rule for this, especially for the numbers (e.g., they are sequential numbers with prefix 00 or 99). The letter is one of C, W, E, F, and R, standing for Convention, Warning, Error, Fatal, and Refactoring. I guess the proper one for the copyright notice would be E as it has to be there. What do you think? |
It seems that the tool can be applied to many types of files, while pylint can only check python files. In this project, Some (if not all) of the bash scripts, TypeScript files, and Jupyter Notebooks also contain a copyright notice. However, if only one type of copyright is adopted here, applying that tool seems like overkill. It complicates the checking process and increases external dependency. |
@vtomole I have developed the checker and tested it locally. Before creating a pull request, I have several questions:
|
Let's change all the |
https://softwareengineering.stackexchange.com/a/19653/322605 says that it's not legally required that every file have a copyright notice (note: the poster is not a lawyer.) Keeping this in mind, I think the more appropriate emitted error would be |
This PR implements a pylint checker that automatically checks the copyright notice at the beginning of a python file. This task is proposed in [Issue 4564](#4564). The PR consists of the following parts: 1. The implemented pylint checker (dev_tools/pylint_copyright_checker.py) and its test file (dev_tools/pylint_copyright_checker_test.py). The checker reports a message with id "R0001" if there is no copyright notice or the notice does not conform to the standard one. The letter 'R' represents refactoring. The checking can be disabled in the file with pragma `# pylint: disable=wrong-copyright-notice` 2. Modification of pylint-related files (check/pylint, check/pylint-changed-files, dev_tools/conf/.pylintrc) to integrate the new checker into the workflow. 3. Python files that failed in this check. Some copyright notices were wrong (e.g. cirq-core/cirq/circuits/circuit_dag.py and cirq-core/cirq/ops/qubit_order_test.py), and they are corrected. Some files did not have a copyright notice. In this case, the "disable" pragma is added. Note that not all the files need to have a copyright notice, [probably](https://softwareengineering.stackexchange.com/a/19653/322605). After the modification, these files can pass pylint checking again.
This PR implements a pylint checker that automatically checks the copyright notice at the beginning of a python file. This task is proposed in [Issue 4564](quantumlib#4564). The PR consists of the following parts: 1. The implemented pylint checker (dev_tools/pylint_copyright_checker.py) and its test file (dev_tools/pylint_copyright_checker_test.py). The checker reports a message with id "R0001" if there is no copyright notice or the notice does not conform to the standard one. The letter 'R' represents refactoring. The checking can be disabled in the file with pragma `# pylint: disable=wrong-copyright-notice` 2. Modification of pylint-related files (check/pylint, check/pylint-changed-files, dev_tools/conf/.pylintrc) to integrate the new checker into the workflow. 3. Python files that failed in this check. Some copyright notices were wrong (e.g. cirq-core/cirq/circuits/circuit_dag.py and cirq-core/cirq/ops/qubit_order_test.py), and they are corrected. Some files did not have a copyright notice. In this case, the "disable" pragma is added. Note that not all the files need to have a copyright notice, [probably](https://softwareengineering.stackexchange.com/a/19653/322605). After the modification, these files can pass pylint checking again.
This functionality is in now. |
This PR implements a pylint checker that automatically checks the copyright notice at the beginning of a python file. This task is proposed in [Issue 4564](quantumlib#4564). The PR consists of the following parts: 1. The implemented pylint checker (dev_tools/pylint_copyright_checker.py) and its test file (dev_tools/pylint_copyright_checker_test.py). The checker reports a message with id "R0001" if there is no copyright notice or the notice does not conform to the standard one. The letter 'R' represents refactoring. The checking can be disabled in the file with pragma `# pylint: disable=wrong-copyright-notice` 2. Modification of pylint-related files (check/pylint, check/pylint-changed-files, dev_tools/conf/.pylintrc) to integrate the new checker into the workflow. 3. Python files that failed in this check. Some copyright notices were wrong (e.g. cirq-core/cirq/circuits/circuit_dag.py and cirq-core/cirq/ops/qubit_order_test.py), and they are corrected. Some files did not have a copyright notice. In this case, the "disable" pragma is added. Note that not all the files need to have a copyright notice, [probably](https://softwareengineering.stackexchange.com/a/19653/322605). After the modification, these files can pass pylint checking again.
This PR implements a pylint checker that automatically checks the copyright notice at the beginning of a python file. This task is proposed in [Issue 4564](quantumlib#4564). The PR consists of the following parts: 1. The implemented pylint checker (dev_tools/pylint_copyright_checker.py) and its test file (dev_tools/pylint_copyright_checker_test.py). The checker reports a message with id "R0001" if there is no copyright notice or the notice does not conform to the standard one. The letter 'R' represents refactoring. The checking can be disabled in the file with pragma `# pylint: disable=wrong-copyright-notice` 2. Modification of pylint-related files (check/pylint, check/pylint-changed-files, dev_tools/conf/.pylintrc) to integrate the new checker into the workflow. 3. Python files that failed in this check. Some copyright notices were wrong (e.g. cirq-core/cirq/circuits/circuit_dag.py and cirq-core/cirq/ops/qubit_order_test.py), and they are corrected. Some files did not have a copyright notice. In this case, the "disable" pragma is added. Note that not all the files need to have a copyright notice, [probably](https://softwareengineering.stackexchange.com/a/19653/322605). After the modification, these files can pass pylint checking again.
Description of the issue
Maybe pylint could automatically check for copyright notices instead of reviewers needed to keep an eye out. Inspired by #456.
Look into https://stackoverflow.com/questions/51886592/can-pylint-check-for-a-static-comment-copyright-notice-at-the-top-of-all-docum
The text was updated successfully, but these errors were encountered: