From 1737f51cc3e9809ba37ec606b0fbde233c7b7849 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 11 Jul 2024 17:23:38 -0500 Subject: [PATCH 01/25] Working license header formatter --- checks-superstaq/checks_superstaq/__init__.py | 2 + .../checks_superstaq/checks-pyproject.toml | 15 + .../license_header_format_.py | 392 ++++++++++++++++++ checks/license_header_format_.py | 21 + .../general_superstaq/check/__init__.py | 2 + 5 files changed, 432 insertions(+) create mode 100644 checks-superstaq/checks_superstaq/license_header_format_.py create mode 100755 checks/license_header_format_.py diff --git a/checks-superstaq/checks_superstaq/__init__.py b/checks-superstaq/checks_superstaq/__init__.py index 8d8a47b87..490d6016e 100644 --- a/checks-superstaq/checks_superstaq/__init__.py +++ b/checks-superstaq/checks_superstaq/__init__.py @@ -8,6 +8,7 @@ coverage_, flake8_, format_, + license_header_format_, mypy_, pylint_, pytest_, @@ -23,6 +24,7 @@ "coverage_", "flake8_", "format_", + "license_header_format_", "mypy_", "pylint_", "pytest_", diff --git a/checks-superstaq/checks_superstaq/checks-pyproject.toml b/checks-superstaq/checks_superstaq/checks-pyproject.toml index 28fa3c114..773cbe840 100644 --- a/checks-superstaq/checks_superstaq/checks-pyproject.toml +++ b/checks-superstaq/checks_superstaq/checks-pyproject.toml @@ -1,3 +1,18 @@ +[tool.license_header_format] +license_header = """# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" # Check script configuration: [tool.pytest.ini_options] diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py new file mode 100644 index 000000000..ddc758114 --- /dev/null +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -0,0 +1,392 @@ +#!/usr/bin/env python3 + +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +import enum +import re +import sys +import textwrap +import tomllib +from collections.abc import Iterable + +from checks_superstaq import check_utils + +# The license header that should be added to the files with no license headers is read from +# the pyproject.toml file. It should be under [tool.license_header_format] assigned to the variable +# license_header +with open("pyproject.toml", "rb") as pyproject: + try: + data = tomllib.load(pyproject) + expected_license_header = data["tool"]["license_header_format"]["license_header"] + in_server = "Apache" not in expected_license_header + # print(expected_license_header) + except KeyError: + raise KeyError( + "Under [tool.license_header_format] add a license_header field with the license\ + header that should be added to source code files in the repository." + ) + +class HeaderType(enum.Enum): + """Enum used to store the types of licence headers that be found in source code files. + + - VALID: valid Infleqtion license header. + - OTHER_APACHE: An Apache license header that is not Infleqtion's. + - OUTDATED: A license belonging to ColdQuanta Inc. + - OTHER: Any other licenses. + """ + VALID = 1 + OTHER_APACHE = 2 + OUTDATED = 3 + OTHER = 4 + +class LicenseHeader(): + """Class to describe license headers found in files including the header itself, the line + numbers where it is found in a file, and the type of the license header.""" + + def __init__(self, start_line_num: int) -> None: + self.start_line_num = start_line_num + self.license_header = "" + self.end_line_num = 0 + + @property + def header_type(self) -> HeaderType: + """Returns the type of the license header.""" + return self._header_type + + @header_type.setter + def header_type(self, header_type: HeaderType) -> None: + """Sets the type of the license header.""" + self._header_type = header_type + + def __str__(self) -> str: + """The string representation of a license header used later for printing.""" + return f""" + Beginning at line: {self.start_line_num} + Ending at line : {self.end_line_num}\n +{self.license_header}\n""" + + +def _extract_license_header(file: str) -> list[LicenseHeader]: + """Extracts the license headers from a file. Reads the file until it finds a none comment line. + Pylint and mypy disabling comments and shebangs are ignored. White spaces preciding the + license header and between the header and shebang and/or pylint line are also ignored. + Also checks if the comment block selected contains the keyword 'Copyright'. + + Args: + file: The file name/path. + + Returns a list of LicenseHeader object each for being the distinct license headers found in + the file. + """ + license_header_lst: list[LicenseHeader] = [] + license_header = "" + exceptions = ["# pylint:", "#!/", "# mypy:"] + + with open(file, "r+") as f: + for line_num, line in enumerate(f): + if not license_header and line[0] == "\n": + continue + if line[0] != "#" and line[0] != "\n": + if license_header: + license_header_lst[-1].license_header = license_header + license_header_lst[-1].end_line_num = line_num + 1 + license_header = "" + break + + if all(exception not in line for exception in exceptions): + if not license_header: + license_header_lst.append(LicenseHeader(line_num + 1)) + + if(line == "\n"): + # set the line number for the last line of the license_header + license_header_lst[-1].license_header = license_header + license_header_lst[-1].end_line_num = line_num + 1 + license_header = "" + else: + license_header += line + license_header_lst = [header for header in license_header_lst if "Copyright" in header.license_header] + + return license_header_lst + + +def _validate_license_header(license_header_lst: list[LicenseHeader]) -> bool: + """Returns whether there is a valid Infleqtion license header in a file and for each license + header in a file, it assigns each theiir type. + - VALID: if the header contains a Copyright Infleqtion line. + - OUTDATED: if the header is for ColdQuanta Inc. + - OTHER_APACHE: if the header is an Apache license but not from Infleqtion + for client-superstaq. + - OTHER: if the header is any other one. Also includes Apache license headers for + server-superstaq. + Args: + license_header_lst: List of the license_header objects for each header in a file. + + Returns: Whether there is a valid license header in a file or not. + """ + valid_header_regex = re.compile(r"(.*)Copyright(.*)Infleqtion") + outdated_header_regex = re.compile(r"(.*)Copyright(.*)ColdQuanta Inc\.") + valid = False + + for license_header in license_header_lst: + if re.search(outdated_header_regex, license_header.license_header): + license_header.header_type = HeaderType.OUTDATED + elif re.search(valid_header_regex, license_header.license_header): + license_header.header_type = HeaderType.VALID + valid = True + elif in_server or "Apache" not in license_header.license_header: + license_header.header_type = HeaderType.OTHER + else: + license_header.header_type = HeaderType.OTHER_APACHE + + return valid + +def _append_to_header(file: str, license_header: LicenseHeader) -> None: + """Appends Infleqtion to existing Apache license that is not from Infleqtion. + + Args: + file: The name/path for the file whose license header will have Infleqtion added to it. + license_header: The specific license header that Infleqtion is being appended to. + + Returns nothing. + """ + prepend = "" + char_count = 0 + with open(file, "r+") as f: + for line_num, line in enumerate(f): + char_count += len(line) + if ("Copyright" in line and + license_header.start_line_num <= line_num + 1 < license_header.end_line_num): + if line[-2] == ",": + prepend += line[:-1] + " 2024 Infleqtion.\n" + else: + prepend += line[:-2] + ", 2024 Infleqtion.\n" + break + prepend += line + + f.seek(char_count) + content = f.read() + f.seek(0) + f.write(prepend+ content) + f.truncate() + + +def _remove_header(file: str, license_header: LicenseHeader) -> None: + """Removes a license header from a file. + + Args: + file: The file name/path from which the bad license header is removed. + license_header: The specific license header that is being removed. + + Returns nothing. + """ + char_count = 0 + prepend = "" + + with open(file, "r+") as f: + for line_num, line in enumerate(f): + if line_num + 1 < license_header.start_line_num: + prepend += line + if line_num + 1 == license_header.end_line_num: + break + char_count += len(line) + + f.seek(char_count) + append = f.read() + + f.seek(0) + f.write(prepend + append) + f.truncate() + + +def _add_license_header(file: str) -> None: + """Adds the correct license header to a file. + + Args: + file: The file name/path to which license header is added. + + Returns nothing. + """ + exceptions = ["# pylint:", "#!/", "# mypy:"] + exception_lines = "" + char_count = 0 + with open(file, "r+") as f: + for line in f: + if any(line.startswith(exception) for exception in exceptions): + exception_lines += line + char_count += len(line) + else: + break + + f.seek(char_count) + content = f.read() + f.seek(0) + f.write(exception_lines + expected_license_header + content) + f.truncate() + +def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_header: bool) -> int: + """For a given file, checks if it has the correct license header. If apply is set to True, + it removes any bad license headers that have been found and replaces them with the correct + license header. + + Args: + file: The file name/path from which the bad license header is removed. + apply: Whether to fix the license header if it is incorrect. + silent: Whether to print out any incorrect license headers that have been found. + no_header: Whether to only handle files with no license headers. + bad_header: Whether to only handle files with incorrect headers. + + Returns the exit code. 1 if an incorrect or no license header is found. 0 if correct. + + """ + license_header_lst: list[LicenseHeader] = _extract_license_header(file) + file_name = check_utils.styled(file, check_utils.Style.BOLD) + + if len(license_header_lst) == 0: + # check if the --no-header flag is set or neither --no-header or --bad-header are set + if ((not no_header and not bad_header) or no_header): + print(f"{file_name}: {check_utils.warning('No license header found.')}") + if apply: + _add_license_header(file) + print(f"{file_name}: {check_utils.success('License header added.')}") + return 1 + else: + return 0 + + if (no_header and not bad_header): # if the --no-header flag is set + return 0 + + valid = _validate_license_header(license_header_lst) + append_flag = False # used to make sure Infleqtion is not appended to multiple Apace headers + exit_code = 0 + + # A file has an incorrect license header if it has no valid Infleqtion license header or + # has an outdated ColdQuanta Inc license. + if not valid or any(header.header_type == HeaderType.OUTDATED for header in license_header_lst): + exit_code = 1 + print(f"{file_name}: {check_utils.warning('Incorrect license header found.')}") + + for license_header in license_header_lst: + match license_header.header_type: + case HeaderType.OTHER_APACHE: + if not valid and not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + # don't append Infleqtion to Apache license if there is a valid Infleqtion + # license header already or it has already been appended to a license. + if not append_flag and apply and not valid: + _append_to_header(file, license_header) + append_flag = True + print(f"{file_name}: {check_utils.success('License header fixed.')}") + case HeaderType.OUTDATED: + if not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + if apply: + _remove_header(file, license_header) + print(f"{file_name}: {check_utils.success('License header removed.')}") + case HeaderType.OTHER: + if not silent and not valid: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + + if not valid and not append_flag: + if apply: + _add_license_header(file) + print(f"{file_name}: {check_utils.success('License header added.')}") + + return exit_code + + +@check_utils.enable_exit_on_failure +def run( + *args: str, + include: str | Iterable[str] = "*.py", + exclude: str | Iterable[str] = (), + silent: bool = False, +) -> int: + """Sets up command line arguments and runs the license header check on all entered files. + + Args: + *args: Command line arguments. + include: Glob(s) indicating which tracked files to consider (e.g. "*.py"). + exclude: Glob(s) indicating which tracked files to skip (e.g. "*integration_test.py"). + silent: If True, restrict printing to warning and error messages. + + Returns: + Terminal exit code. 0 indicates success, while any other integer indicates a test failure. + """ + + parser = check_utils.get_check_parser() + parser.description = textwrap.dedent( + """ + Runs the license header formatter on the repository. + """ + ) + parser.add_argument( + "--apply", action="store_true", help="Add the license header to files.", default=False + ) + + target_case = parser.add_mutually_exclusive_group() + target_case.add_argument( + "--no-header", + action="store_true", + help="Hanlde only files with no license header.", + default=False, + ) + target_case.add_argument( + "--bad-header", + action="store_true", + help="Handle only files with incorrect license headers.", + default=False, + ) + parser.add_argument( + "--silent", + action="store_true", + help="Do not show incorrect license headers.", + default=False, + ) + + parsed_args, _ = parser.parse_known_intermixed_args(args) + if "license_check" in parsed_args.skip: + return 0 + + files = check_utils.extract_files(parsed_args, include, exclude, silent) + if not files: + print("No files selected.\n") + return 0 + + exit_code = 0 + for file in files: + exit_code |= run_checker( + file, + parsed_args.apply, + parsed_args.silent, + parsed_args.no_header, + parsed_args.bad_header, + ) + + if not exit_code: + print(check_utils.success("All license headers correct!")) + + return exit_code + + +if __name__ == "__main__": + exit(run(*sys.argv[1:])) diff --git a/checks/license_header_format_.py b/checks/license_header_format_.py new file mode 100755 index 000000000..ef2ef204f --- /dev/null +++ b/checks/license_header_format_.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +import checks_superstaq as checks + +if __name__ == "__main__": + exit(checks.license_header_format_.run(*sys.argv[1:])) diff --git a/general-superstaq/general_superstaq/check/__init__.py b/general-superstaq/general_superstaq/check/__init__.py index 0a91e9bce..a75bf9464 100644 --- a/general-superstaq/general_superstaq/check/__init__.py +++ b/general-superstaq/general_superstaq/check/__init__.py @@ -7,6 +7,7 @@ coverage_, flake8_, format_, + license_header_format_, mypy_, pylint_, pytest_, @@ -22,6 +23,7 @@ "coverage_", "flake8_", "format_", + "license_header_format_", "mypy_", "pylint_", "pytest_", From c274c3919186c00d1b959565d7b7aa443e9e1b62 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 11 Jul 2024 17:36:14 -0500 Subject: [PATCH 02/25] Fix formatting --- .../license_header_format_.py | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index ddc758114..7a33a0948 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -40,20 +40,23 @@ header that should be added to source code files in the repository." ) + class HeaderType(enum.Enum): """Enum used to store the types of licence headers that be found in source code files. - - - VALID: valid Infleqtion license header. - - OTHER_APACHE: An Apache license header that is not Infleqtion's. - - OUTDATED: A license belonging to ColdQuanta Inc. - - OTHER: Any other licenses. + + - VALID: valid Infleqtion license header. + - OTHER_APACHE: An Apache license header that is not Infleqtion's. + - OUTDATED: A license belonging to ColdQuanta Inc. + - OTHER: Any other licenses. """ + VALID = 1 OTHER_APACHE = 2 OUTDATED = 3 OTHER = 4 -class LicenseHeader(): + +class LicenseHeader: """Class to describe license headers found in files including the header itself, the line numbers where it is found in a file, and the type of the license header.""" @@ -89,7 +92,7 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: Args: file: The file name/path. - Returns a list of LicenseHeader object each for being the distinct license headers found in + Returns a list of LicenseHeader object each for being the distinct license headers found in the file. """ license_header_lst: list[LicenseHeader] = [] @@ -111,21 +114,23 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: if not license_header: license_header_lst.append(LicenseHeader(line_num + 1)) - if(line == "\n"): + if line == "\n": # set the line number for the last line of the license_header license_header_lst[-1].license_header = license_header license_header_lst[-1].end_line_num = line_num + 1 license_header = "" else: license_header += line - license_header_lst = [header for header in license_header_lst if "Copyright" in header.license_header] - + license_header_lst = [ + header for header in license_header_lst if "Copyright" in header.license_header + ] + return license_header_lst def _validate_license_header(license_header_lst: list[LicenseHeader]) -> bool: """Returns whether there is a valid Infleqtion license header in a file and for each license - header in a file, it assigns each theiir type. + header in a file, it assigns each theiir type. - VALID: if the header contains a Copyright Infleqtion line. - OUTDATED: if the header is for ColdQuanta Inc. - OTHER_APACHE: if the header is an Apache license but not from Infleqtion @@ -140,7 +145,7 @@ def _validate_license_header(license_header_lst: list[LicenseHeader]) -> bool: valid_header_regex = re.compile(r"(.*)Copyright(.*)Infleqtion") outdated_header_regex = re.compile(r"(.*)Copyright(.*)ColdQuanta Inc\.") valid = False - + for license_header in license_header_lst: if re.search(outdated_header_regex, license_header.license_header): license_header.header_type = HeaderType.OUTDATED @@ -150,10 +155,11 @@ def _validate_license_header(license_header_lst: list[LicenseHeader]) -> bool: elif in_server or "Apache" not in license_header.license_header: license_header.header_type = HeaderType.OTHER else: - license_header.header_type = HeaderType.OTHER_APACHE + license_header.header_type = HeaderType.OTHER_APACHE return valid + def _append_to_header(file: str, license_header: LicenseHeader) -> None: """Appends Infleqtion to existing Apache license that is not from Infleqtion. @@ -168,8 +174,10 @@ def _append_to_header(file: str, license_header: LicenseHeader) -> None: with open(file, "r+") as f: for line_num, line in enumerate(f): char_count += len(line) - if ("Copyright" in line and - license_header.start_line_num <= line_num + 1 < license_header.end_line_num): + if ( + "Copyright" in line + and license_header.start_line_num <= line_num + 1 < license_header.end_line_num + ): if line[-2] == ",": prepend += line[:-1] + " 2024 Infleqtion.\n" else: @@ -180,7 +188,7 @@ def _append_to_header(file: str, license_header: LicenseHeader) -> None: f.seek(char_count) content = f.read() f.seek(0) - f.write(prepend+ content) + f.write(prepend + content) f.truncate() @@ -189,7 +197,7 @@ def _remove_header(file: str, license_header: LicenseHeader) -> None: Args: file: The file name/path from which the bad license header is removed. - license_header: The specific license header that is being removed. + license_header: The specific license header that is being removed. Returns nothing. """ @@ -198,10 +206,10 @@ def _remove_header(file: str, license_header: LicenseHeader) -> None: with open(file, "r+") as f: for line_num, line in enumerate(f): - if line_num + 1 < license_header.start_line_num: + if line_num + 1 < license_header.start_line_num: prepend += line if line_num + 1 == license_header.end_line_num: - break + break char_count += len(line) f.seek(char_count) @@ -237,6 +245,7 @@ def _add_license_header(file: str) -> None: f.write(exception_lines + expected_license_header + content) f.truncate() + def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_header: bool) -> int: """For a given file, checks if it has the correct license header. If apply is set to True, it removes any bad license headers that have been found and replaces them with the correct @@ -257,7 +266,7 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade if len(license_header_lst) == 0: # check if the --no-header flag is set or neither --no-header or --bad-header are set - if ((not no_header and not bad_header) or no_header): + if (not no_header and not bad_header) or no_header: print(f"{file_name}: {check_utils.warning('No license header found.')}") if apply: _add_license_header(file) @@ -266,17 +275,17 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade else: return 0 - if (no_header and not bad_header): # if the --no-header flag is set + if no_header and not bad_header: # if the --no-header flag is set return 0 valid = _validate_license_header(license_header_lst) - append_flag = False # used to make sure Infleqtion is not appended to multiple Apace headers + append_flag = False # used to make sure Infleqtion is not appended to multiple Apace headers exit_code = 0 # A file has an incorrect license header if it has no valid Infleqtion license header or # has an outdated ColdQuanta Inc license. if not valid or any(header.header_type == HeaderType.OUTDATED for header in license_header_lst): - exit_code = 1 + exit_code = 1 print(f"{file_name}: {check_utils.warning('Incorrect license header found.')}") for license_header in license_header_lst: @@ -289,7 +298,7 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade # don't append Infleqtion to Apache license if there is a valid Infleqtion # license header already or it has already been appended to a license. if not append_flag and apply and not valid: - _append_to_header(file, license_header) + _append_to_header(file, license_header) append_flag = True print(f"{file_name}: {check_utils.success('License header fixed.')}") case HeaderType.OUTDATED: @@ -305,7 +314,7 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade print("----------") print(check_utils.warning(str(license_header))) print("----------") - + if not valid and not append_flag: if apply: _add_license_header(file) From 8fde62bfb451b3f97a84c66fde6e61491ded7069 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 11 Jul 2024 17:39:05 -0500 Subject: [PATCH 03/25] Remove match case to if statements --- .../license_header_format_.py | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 7a33a0948..a36ff4c88 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -289,31 +289,30 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade print(f"{file_name}: {check_utils.warning('Incorrect license header found.')}") for license_header in license_header_lst: - match license_header.header_type: - case HeaderType.OTHER_APACHE: - if not valid and not silent: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") - # don't append Infleqtion to Apache license if there is a valid Infleqtion - # license header already or it has already been appended to a license. - if not append_flag and apply and not valid: - _append_to_header(file, license_header) - append_flag = True - print(f"{file_name}: {check_utils.success('License header fixed.')}") - case HeaderType.OUTDATED: - if not silent: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") - if apply: - _remove_header(file, license_header) - print(f"{file_name}: {check_utils.success('License header removed.')}") - case HeaderType.OTHER: - if not silent and not valid: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") + if license_header.header_type == HeaderType.OTHER_APACHE: + if not valid and not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + # don't append Infleqtion to Apache license if there is a valid Infleqtion + # license header already or it has already been appended to a license. + if not append_flag and apply and not valid: + _append_to_header(file, license_header) + append_flag = True + print(f"{file_name}: {check_utils.success('License header fixed.')}") + elif license_header.header_type == HeaderType.OUTDATED: + if not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + if apply: + _remove_header(file, license_header) + print(f"{file_name}: {check_utils.success('License header removed.')}") + elif license_header.header_type == HeaderType.OTHER: + if not silent and not valid: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") if not valid and not append_flag: if apply: From 06cc52ad14c20c95ae835312badabbc4e63a421a Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 11 Jul 2024 18:18:29 -0500 Subject: [PATCH 04/25] Reduce complexity --- .../license_header_format_.py | 105 ++++++++++++------ 1 file changed, 70 insertions(+), 35 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index a36ff4c88..4e845f5b8 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -246,6 +246,58 @@ def _add_license_header(file: str) -> None: f.truncate() +def handle_bad_header( + file: str, + styled_file_name: str, + license_header: LicenseHeader, + apply: bool, + valid: bool, + silent: bool, + append_flag: bool, +) -> bool: + """Function handles bad headers in files. The cases are handled according to the HeaderType: + - VALID and OTHER: no change. + - OTHER_APACHE: the first of this type will have Infleqtion appended to license header. + - OUTDATED: will be removed + + Args: + file: The file name/path from which the bad license header is removed. + styled_file_name: Styled file name. + license_header: The LicenseHeader object of the currect header being handled. + apply: Whether to fix the license header if it is incorrect. + valid: Whether there is a valid header in the file. + silent: Whether to print out any incorrect license headers that have been found. + append_flag: Whether Infleqtion has already been appended to an Apache License in the file. + + Returns the updated append_flag. + """ + if license_header.header_type == HeaderType.OTHER_APACHE: + if not valid and not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + # don't append Infleqtion to Apache license if there is a valid Infleqtion + # license header already or it has already been appended to a license. + if not append_flag and apply and not valid: + _append_to_header(file, license_header) + append_flag = True + print(f"{styled_file_name}: {check_utils.success('License header fixed.')}") + elif license_header.header_type == HeaderType.OUTDATED: + if not silent: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + if apply: + _remove_header(file, license_header) + print(f"{styled_file_name}: {check_utils.success('License header removed.')}") + elif license_header.header_type == HeaderType.OTHER: + if not silent and not valid: + print("----------") + print(check_utils.warning(str(license_header))) + print("----------") + return append_flag + + def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_header: bool) -> int: """For a given file, checks if it has the correct license header. If apply is set to True, it removes any bad license headers that have been found and replaces them with the correct @@ -259,21 +311,20 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade bad_header: Whether to only handle files with incorrect headers. Returns the exit code. 1 if an incorrect or no license header is found. 0 if correct. - """ license_header_lst: list[LicenseHeader] = _extract_license_header(file) - file_name = check_utils.styled(file, check_utils.Style.BOLD) + styled_file_name = check_utils.styled(file, check_utils.Style.BOLD) if len(license_header_lst) == 0: - # check if the --no-header flag is set or neither --no-header or --bad-header are set if (not no_header and not bad_header) or no_header: - print(f"{file_name}: {check_utils.warning('No license header found.')}") + print(f"{styled_file_name}: {check_utils.warning('No license header found.')}") if apply: _add_license_header(file) - print(f"{file_name}: {check_utils.success('License header added.')}") + print(f"{styled_file_name}: {check_utils.success('License header added.')}") return 1 else: return 0 + # return handle_no_header(file, apply, no_header, bad_header) if no_header and not bad_header: # if the --no-header flag is set return 0 @@ -286,38 +337,22 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade # has an outdated ColdQuanta Inc license. if not valid or any(header.header_type == HeaderType.OUTDATED for header in license_header_lst): exit_code = 1 - print(f"{file_name}: {check_utils.warning('Incorrect license header found.')}") + print(f"{styled_file_name}: {check_utils.warning('Incorrect license header found.')}") for license_header in license_header_lst: - if license_header.header_type == HeaderType.OTHER_APACHE: - if not valid and not silent: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") - # don't append Infleqtion to Apache license if there is a valid Infleqtion - # license header already or it has already been appended to a license. - if not append_flag and apply and not valid: - _append_to_header(file, license_header) - append_flag = True - print(f"{file_name}: {check_utils.success('License header fixed.')}") - elif license_header.header_type == HeaderType.OUTDATED: - if not silent: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") - if apply: - _remove_header(file, license_header) - print(f"{file_name}: {check_utils.success('License header removed.')}") - elif license_header.header_type == HeaderType.OTHER: - if not silent and not valid: - print("----------") - print(check_utils.warning(str(license_header))) - print("----------") - - if not valid and not append_flag: - if apply: - _add_license_header(file) - print(f"{file_name}: {check_utils.success('License header added.')}") + append_flag = handle_bad_header( + file, + styled_file_name, + license_header, + apply, + valid, + silent, + append_flag, + ) + + if not valid and not append_flag and apply: + _add_license_header(file) + print(f"{styled_file_name}: {check_utils.success('License header added.')}") return exit_code From d8a052c6526c86a1a7b683771e4672240e07380b Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 16:54:34 -0500 Subject: [PATCH 05/25] Toml reading fixed for older python versions, improved printing --- .../license_header_format_.py | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 4e845f5b8..1a3bfecc7 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -20,25 +20,25 @@ import re import sys import textwrap -import tomllib from collections.abc import Iterable +from pathlib import Path + +import tomlkit from checks_superstaq import check_utils # The license header that should be added to the files with no license headers is read from # the pyproject.toml file. It should be under [tool.license_header_format] assigned to the variable # license_header -with open("pyproject.toml", "rb") as pyproject: - try: - data = tomllib.load(pyproject) - expected_license_header = data["tool"]["license_header_format"]["license_header"] - in_server = "Apache" not in expected_license_header - # print(expected_license_header) - except KeyError: - raise KeyError( - "Under [tool.license_header_format] add a license_header field with the license\ - header that should be added to source code files in the repository." - ) +try: + data = tomlkit.loads(Path("pyproject.toml").read_text()) + expected_license_header = data["tool"]["license_header_format"]["license_header"] + in_server = "Apache" not in expected_license_header +except KeyError: + raise KeyError( + "Under [tool.license_header_format] add a license_header field with the license\ + heder that should be added to source code files in the repository." + ) class HeaderType(enum.Enum): @@ -272,7 +272,7 @@ def handle_bad_header( Returns the updated append_flag. """ if license_header.header_type == HeaderType.OTHER_APACHE: - if not valid and not silent: + if not valid and not silent and not apply: print("----------") print(check_utils.warning(str(license_header))) print("----------") @@ -283,7 +283,7 @@ def handle_bad_header( append_flag = True print(f"{styled_file_name}: {check_utils.success('License header fixed.')}") elif license_header.header_type == HeaderType.OUTDATED: - if not silent: + if not silent and not apply: print("----------") print(check_utils.warning(str(license_header))) print("----------") @@ -291,7 +291,7 @@ def handle_bad_header( _remove_header(file, license_header) print(f"{styled_file_name}: {check_utils.success('License header removed.')}") elif license_header.header_type == HeaderType.OTHER: - if not silent and not valid: + if not silent and not valid and not apply: print("----------") print(check_utils.warning(str(license_header))) print("----------") @@ -317,10 +317,11 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade if len(license_header_lst) == 0: if (not no_header and not bad_header) or no_header: - print(f"{styled_file_name}: {check_utils.warning('No license header found.')}") if apply: _add_license_header(file) print(f"{styled_file_name}: {check_utils.success('License header added.')}") + else: + print(f"{styled_file_name}: {check_utils.warning('No license header found.')}") return 1 else: return 0 @@ -420,13 +421,20 @@ def run( exit_code |= run_checker( file, parsed_args.apply, - parsed_args.silent, + parsed_args.silent or silent, parsed_args.no_header, parsed_args.bad_header, ) if not exit_code: - print(check_utils.success("All license headers correct!")) + print(check_utils.success("All license headers are correct!")) + elif not parsed_args.apply: + print( + check_utils.warning( + "Run './checks/license_header_format_.py --apply' (from the repo root directory) to" + " fix the license headers." + ) + ) return exit_code From 4dbc5c456de8051472184add7b5f09e16019c19f Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:00:38 -0500 Subject: [PATCH 06/25] Add license_header_format_ to all_.py --- checks-superstaq/checks_superstaq/all_.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/checks-superstaq/checks_superstaq/all_.py b/checks-superstaq/checks_superstaq/all_.py index 58cf45977..710d1dd88 100644 --- a/checks-superstaq/checks_superstaq/all_.py +++ b/checks-superstaq/checks_superstaq/all_.py @@ -11,6 +11,7 @@ coverage_, flake8_, format_, + license_header_format_, mypy_, pylint_, requirements, @@ -69,6 +70,11 @@ def run(*args: str, sphinx_paths: list[str] | None = None) -> int: checks_failed |= format_.run(*args_to_pass, exit_on_failure=exit_on_failure, silent=True) checks_failed |= flake8_.run(*args_to_pass, exit_on_failure=exit_on_failure, silent=True) checks_failed |= pylint_.run(*args_to_pass, exit_on_failure=exit_on_failure, silent=True) + checks_failed |= license_header_format_.run( + *args_to_pass, + exit_on_failure=exit_on_failure, + silent=True, + ) # run typing and coverage checks exit_on_failure = not parsed_args.force_all From 350fbdb3b600536f8470f554e30dddab20dd1a4a Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:06:03 -0500 Subject: [PATCH 07/25] Report number of incorrect license headers --- checks-superstaq/checks_superstaq/license_header_format_.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 1a3bfecc7..2a7617069 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -418,7 +418,7 @@ def run( exit_code = 0 for file in files: - exit_code |= run_checker( + exit_code += run_checker( file, parsed_args.apply, parsed_args.silent or silent, @@ -431,6 +431,7 @@ def run( elif not parsed_args.apply: print( check_utils.warning( + f"{exit_code} issues found.\n" "Run './checks/license_header_format_.py --apply' (from the repo root directory) to" " fix the license headers." ) From 74db2dab2272892e4eb37e6022952f2507ca32ba Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:10:23 -0500 Subject: [PATCH 08/25] Fix print for incorrect header case --- checks-superstaq/checks_superstaq/license_header_format_.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 2a7617069..92db99faa 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -338,7 +338,8 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade # has an outdated ColdQuanta Inc license. if not valid or any(header.header_type == HeaderType.OUTDATED for header in license_header_lst): exit_code = 1 - print(f"{styled_file_name}: {check_utils.warning('Incorrect license header found.')}") + if not apply: + print(f"{styled_file_name}: {check_utils.warning('Incorrect license header found.')}") for license_header in license_header_lst: append_flag = handle_bad_header( From 92e7900a7c8231e0e4f3812e8fc4412567b106e4 Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:22:40 -0500 Subject: [PATCH 09/25] Fix mypy issues --- checks-superstaq/checks_superstaq/license_header_format_.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 92db99faa..442cdb8b7 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -22,6 +22,7 @@ import textwrap from collections.abc import Iterable from pathlib import Path +from typing import Any import tomlkit @@ -31,8 +32,8 @@ # the pyproject.toml file. It should be under [tool.license_header_format] assigned to the variable # license_header try: - data = tomlkit.loads(Path("pyproject.toml").read_text()) - expected_license_header = data["tool"]["license_header_format"]["license_header"] + data: dict[str, Any] = tomlkit.parse(Path("pyproject.toml").read_text()) + expected_license_header = str(data["tool"]["license_header_format"]["license_header"]) in_server = "Apache" not in expected_license_header except KeyError: raise KeyError( From 50750a54ee42bd828fde602beb5fd660ce6906bc Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:24:16 -0500 Subject: [PATCH 10/25] Fix license headers for repo --- checks-superstaq/checks_superstaq/__init__.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/all_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/build_docs.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/check_utils.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/configs.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/coverage_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/flake8_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/format_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/mypy_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/pylint_.py | 13 +++++++++++++ .../checks_superstaq/pylint_init_return.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/pytest_.py | 13 +++++++++++++ checks-superstaq/checks_superstaq/requirements.py | 13 +++++++++++++ checks/all_.py | 13 +++++++++++++ checks/build_docs.py | 13 +++++++++++++ checks/configs.py | 13 +++++++++++++ checks/coverage_.py | 13 +++++++++++++ checks/flake8_.py | 13 +++++++++++++ checks/format_.py | 13 +++++++++++++ checks/mypy_.py | 13 +++++++++++++ checks/pylint_.py | 13 +++++++++++++ checks/pytest_.py | 13 +++++++++++++ checks/requirements.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/__init__.py | 2 +- cirq-superstaq/cirq_superstaq/_version_test.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/compiler_output.py | 13 +++++++++++++ .../cirq_superstaq/compiler_output_test.py | 13 +++++++++++++ .../cirq_superstaq/daily_integration_test.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/job.py | 2 +- cirq-superstaq/cirq_superstaq/job_test.py | 2 +- cirq-superstaq/cirq_superstaq/ops/__init__.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/ops/qubit_gates.py | 13 +++++++++++++ .../cirq_superstaq/ops/qubit_gates_test.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/ops/qudit_gates.py | 13 +++++++++++++ .../cirq_superstaq/ops/qudit_gates_test.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/sampler.py | 2 +- cirq-superstaq/cirq_superstaq/serialization.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/serialization_test.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/service.py | 2 +- cirq-superstaq/cirq_superstaq/service_test.py | 2 +- cirq-superstaq/cirq_superstaq/validation.py | 13 +++++++++++++ cirq-superstaq/cirq_superstaq/validation_test.py | 13 +++++++++++++ dev_tools/locustfile.py | 13 +++++++++++++ docs/source/conf.py | 13 +++++++++++++ general-superstaq/general_superstaq/__init__.py | 13 +++++++++++++ general-superstaq/general_superstaq/_init_vars.py | 13 +++++++++++++ general-superstaq/general_superstaq/_version.py | 13 +++++++++++++ .../general_superstaq/_version_test.py | 13 +++++++++++++ .../general_superstaq/check/__init__.py | 13 +++++++++++++ .../general_superstaq/resource_estimate.py | 13 +++++++++++++ .../general_superstaq/resource_estimate_test.py | 13 +++++++++++++ .../general_superstaq/serialization.py | 13 +++++++++++++ .../general_superstaq/serialization_test.py | 13 +++++++++++++ general-superstaq/general_superstaq/service.py | 13 +++++++++++++ general-superstaq/general_superstaq/service_test.py | 13 +++++++++++++ .../general_superstaq/superstaq_client.py | 2 +- .../general_superstaq/superstaq_client_test.py | 2 +- .../general_superstaq/superstaq_exceptions.py | 13 +++++++++++++ .../general_superstaq/superstaq_exceptions_test.py | 2 +- general-superstaq/general_superstaq/testing.py | 13 +++++++++++++ general-superstaq/general_superstaq/typing.py | 13 +++++++++++++ general-superstaq/general_superstaq/validation.py | 13 +++++++++++++ .../general_superstaq/validation_test.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/__init__.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/_version_test.py | 13 +++++++++++++ .../qiskit_superstaq/compiler_output.py | 13 +++++++++++++ .../qiskit_superstaq/compiler_output_test.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/conftest.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/custom_gates.py | 13 +++++++++++++ .../qiskit_superstaq/custom_gates_test.py | 13 +++++++++++++ .../qiskit_superstaq/daily_integration_test.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/serialization.py | 13 +++++++++++++ .../qiskit_superstaq/serialization_test.py | 13 +++++++++++++ .../qiskit_superstaq/superstaq_backend.py | 2 +- .../qiskit_superstaq/superstaq_backend_test.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/superstaq_job.py | 2 +- .../qiskit_superstaq/superstaq_job_test.py | 13 +++++++++++++ .../qiskit_superstaq/superstaq_provider.py | 2 +- .../qiskit_superstaq/superstaq_provider_test.py | 13 +++++++++++++ qiskit-superstaq/qiskit_superstaq/validation.py | 13 +++++++++++++ .../qiskit_superstaq/validation_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/__init__.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/_version_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/benchmark.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/benchmark_test.py | 13 +++++++++++++ .../supermarq/benchmarks/__init__.py | 13 +++++++++++++ .../supermarq/benchmarks/bit_code.py | 13 +++++++++++++ .../supermarq/benchmarks/bit_code_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/benchmarks/ghz.py | 13 +++++++++++++ .../supermarq/benchmarks/ghz_test.py | 13 +++++++++++++ .../supermarq/benchmarks/hamiltonian_simulation.py | 13 +++++++++++++ .../benchmarks/hamiltonian_simulation_test.py | 13 +++++++++++++ .../supermarq/benchmarks/mermin_bell.py | 13 +++++++++++++ .../supermarq/benchmarks/mermin_bell_test.py | 13 +++++++++++++ .../supermarq/benchmarks/phase_code.py | 13 +++++++++++++ .../supermarq/benchmarks/phase_code_test.py | 13 +++++++++++++ .../benchmarks/qaoa_fermionic_swap_proxy.py | 13 +++++++++++++ .../benchmarks/qaoa_fermionic_swap_proxy_test.py | 13 +++++++++++++ .../supermarq/benchmarks/qaoa_vanilla_proxy.py | 13 +++++++++++++ .../supermarq/benchmarks/qaoa_vanilla_proxy_test.py | 13 +++++++++++++ .../supermarq/benchmarks/vqe_proxy.py | 13 +++++++++++++ .../supermarq/benchmarks/vqe_proxy_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/converters.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/converters_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/features.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/features_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/plotting.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/plotting_test.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/simulation.py | 13 +++++++++++++ supermarq-benchmarks/supermarq/stabilizers.py | 13 +++++++++++++ 110 files changed, 1286 insertions(+), 12 deletions(-) diff --git a/checks-superstaq/checks_superstaq/__init__.py b/checks-superstaq/checks_superstaq/__init__.py index 490d6016e..62b6c5175 100644 --- a/checks-superstaq/checks_superstaq/__init__.py +++ b/checks-superstaq/checks_superstaq/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from checks_superstaq._version import __version__ from . import ( diff --git a/checks-superstaq/checks_superstaq/all_.py b/checks-superstaq/checks_superstaq/all_.py index 710d1dd88..a7bc15029 100644 --- a/checks-superstaq/checks_superstaq/all_.py +++ b/checks-superstaq/checks_superstaq/all_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import sys diff --git a/checks-superstaq/checks_superstaq/build_docs.py b/checks-superstaq/checks_superstaq/build_docs.py index 7ebced64b..6cf36b1e9 100755 --- a/checks-superstaq/checks_superstaq/build_docs.py +++ b/checks-superstaq/checks_superstaq/build_docs.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import os diff --git a/checks-superstaq/checks_superstaq/check_utils.py b/checks-superstaq/checks_superstaq/check_utils.py index 07061bd85..0c763816e 100644 --- a/checks-superstaq/checks_superstaq/check_utils.py +++ b/checks-superstaq/checks_superstaq/check_utils.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Dumping ground for check script utilities.""" from __future__ import annotations diff --git a/checks-superstaq/checks_superstaq/configs.py b/checks-superstaq/checks_superstaq/configs.py index 3d172d80d..e308d7a89 100644 --- a/checks-superstaq/checks_superstaq/configs.py +++ b/checks-superstaq/checks_superstaq/configs.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import difflib diff --git a/checks-superstaq/checks_superstaq/coverage_.py b/checks-superstaq/checks_superstaq/coverage_.py index 3d16a89eb..c4b661e82 100644 --- a/checks-superstaq/checks_superstaq/coverage_.py +++ b/checks-superstaq/checks_superstaq/coverage_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import os diff --git a/checks-superstaq/checks_superstaq/flake8_.py b/checks-superstaq/checks_superstaq/flake8_.py index 105865fee..94dea667f 100644 --- a/checks-superstaq/checks_superstaq/flake8_.py +++ b/checks-superstaq/checks_superstaq/flake8_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import subprocess diff --git a/checks-superstaq/checks_superstaq/format_.py b/checks-superstaq/checks_superstaq/format_.py index e3d9475e0..cf0d205ee 100644 --- a/checks-superstaq/checks_superstaq/format_.py +++ b/checks-superstaq/checks_superstaq/format_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import subprocess diff --git a/checks-superstaq/checks_superstaq/mypy_.py b/checks-superstaq/checks_superstaq/mypy_.py index 1908eb3f5..1910237d0 100644 --- a/checks-superstaq/checks_superstaq/mypy_.py +++ b/checks-superstaq/checks_superstaq/mypy_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import subprocess diff --git a/checks-superstaq/checks_superstaq/pylint_.py b/checks-superstaq/checks_superstaq/pylint_.py index e610613a7..0d36cf160 100644 --- a/checks-superstaq/checks_superstaq/pylint_.py +++ b/checks-superstaq/checks_superstaq/pylint_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import multiprocessing diff --git a/checks-superstaq/checks_superstaq/pylint_init_return.py b/checks-superstaq/checks_superstaq/pylint_init_return.py index 2ec664971..9fd3bb4f9 100644 --- a/checks-superstaq/checks_superstaq/pylint_init_return.py +++ b/checks-superstaq/checks_superstaq/pylint_init_return.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Check return type annotation of __init__ functions.""" from __future__ import annotations diff --git a/checks-superstaq/checks_superstaq/pytest_.py b/checks-superstaq/checks_superstaq/pytest_.py index 9cb07ba19..00ccd19f9 100644 --- a/checks-superstaq/checks_superstaq/pytest_.py +++ b/checks-superstaq/checks_superstaq/pytest_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import re diff --git a/checks-superstaq/checks_superstaq/requirements.py b/checks-superstaq/checks_superstaq/requirements.py index 7c448fdfe..b2b08c300 100644 --- a/checks-superstaq/checks_superstaq/requirements.py +++ b/checks-superstaq/checks_superstaq/requirements.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import fnmatch diff --git a/checks/all_.py b/checks/all_.py index 3a520156f..728d53acd 100755 --- a/checks/all_.py +++ b/checks/all_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/build_docs.py b/checks/build_docs.py index 032c6bfe1..b29ce3589 100755 --- a/checks/build_docs.py +++ b/checks/build_docs.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/configs.py b/checks/configs.py index cb1fa8f73..c5abdb266 100755 --- a/checks/configs.py +++ b/checks/configs.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/coverage_.py b/checks/coverage_.py index 85b141261..feb4ebe37 100755 --- a/checks/coverage_.py +++ b/checks/coverage_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/flake8_.py b/checks/flake8_.py index 2bfd0743d..9bc8f8928 100755 --- a/checks/flake8_.py +++ b/checks/flake8_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/format_.py b/checks/format_.py index 14a795be9..bed358c9d 100755 --- a/checks/format_.py +++ b/checks/format_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/mypy_.py b/checks/mypy_.py index ea2eed9a5..919f6251d 100755 --- a/checks/mypy_.py +++ b/checks/mypy_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/pylint_.py b/checks/pylint_.py index 4660c3f7d..19b46f944 100755 --- a/checks/pylint_.py +++ b/checks/pylint_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/pytest_.py b/checks/pytest_.py index 4478a3578..965369d71 100755 --- a/checks/pytest_.py +++ b/checks/pytest_.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/checks/requirements.py b/checks/requirements.py index 58cbc72e0..b74f0644c 100755 --- a/checks/requirements.py +++ b/checks/requirements.py @@ -1,4 +1,17 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import sys import checks_superstaq as checks diff --git a/cirq-superstaq/cirq_superstaq/__init__.py b/cirq-superstaq/cirq_superstaq/__init__.py index 5b2aad57f..d92c111e8 100644 --- a/cirq-superstaq/cirq_superstaq/__init__.py +++ b/cirq-superstaq/cirq_superstaq/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/_version_test.py b/cirq-superstaq/cirq_superstaq/_version_test.py index d69b874d0..7d516b97f 100644 --- a/cirq-superstaq/cirq_superstaq/_version_test.py +++ b/cirq-superstaq/cirq_superstaq/_version_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import packaging.version import cirq_superstaq as css diff --git a/cirq-superstaq/cirq_superstaq/compiler_output.py b/cirq-superstaq/cirq_superstaq/compiler_output.py index 1ceaeee0d..e800b7239 100644 --- a/cirq-superstaq/cirq_superstaq/compiler_output.py +++ b/cirq-superstaq/cirq_superstaq/compiler_output.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import importlib.util diff --git a/cirq-superstaq/cirq_superstaq/compiler_output_test.py b/cirq-superstaq/cirq_superstaq/compiler_output_test.py index 95d4214ff..569d44d4f 100644 --- a/cirq-superstaq/cirq_superstaq/compiler_output_test.py +++ b/cirq-superstaq/cirq_superstaq/compiler_output_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import importlib diff --git a/cirq-superstaq/cirq_superstaq/daily_integration_test.py b/cirq-superstaq/cirq_superstaq/daily_integration_test.py index ea9d8b8ab..33cf00fa2 100644 --- a/cirq-superstaq/cirq_superstaq/daily_integration_test.py +++ b/cirq-superstaq/cirq_superstaq/daily_integration_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Integration checks that run daily (via Github action) between client and prod server.""" from __future__ import annotations diff --git a/cirq-superstaq/cirq_superstaq/job.py b/cirq-superstaq/cirq_superstaq/job.py index fd4bf30ce..b05b09618 100644 --- a/cirq-superstaq/cirq_superstaq/job.py +++ b/cirq-superstaq/cirq_superstaq/job.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/job_test.py b/cirq-superstaq/cirq_superstaq/job_test.py index 31c9fbd5a..ac1d98fdb 100644 --- a/cirq-superstaq/cirq_superstaq/job_test.py +++ b/cirq-superstaq/cirq_superstaq/job_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/ops/__init__.py b/cirq-superstaq/cirq_superstaq/ops/__init__.py index 32a3d0b12..269b9e584 100644 --- a/cirq-superstaq/cirq_superstaq/ops/__init__.py +++ b/cirq-superstaq/cirq_superstaq/ops/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from .qubit_gates import ( AQTICCX, AQTITOFFOLI, diff --git a/cirq-superstaq/cirq_superstaq/ops/qubit_gates.py b/cirq-superstaq/cirq_superstaq/ops/qubit_gates.py index 0dc24d0ed..f36d5053a 100644 --- a/cirq-superstaq/cirq_superstaq/ops/qubit_gates.py +++ b/cirq-superstaq/cirq_superstaq/ops/qubit_gates.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Miscellaneous custom gates that we encounter and want to explicitly define.""" from __future__ import annotations diff --git a/cirq-superstaq/cirq_superstaq/ops/qubit_gates_test.py b/cirq-superstaq/cirq_superstaq/ops/qubit_gates_test.py index 9694f3240..0c0112cb4 100644 --- a/cirq-superstaq/cirq_superstaq/ops/qubit_gates_test.py +++ b/cirq-superstaq/cirq_superstaq/ops/qubit_gates_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import itertools import json import textwrap diff --git a/cirq-superstaq/cirq_superstaq/ops/qudit_gates.py b/cirq-superstaq/cirq_superstaq/ops/qudit_gates.py index 7199a9eb2..bbb072f91 100644 --- a/cirq-superstaq/cirq_superstaq/ops/qudit_gates.py +++ b/cirq-superstaq/cirq_superstaq/ops/qudit_gates.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import abc diff --git a/cirq-superstaq/cirq_superstaq/ops/qudit_gates_test.py b/cirq-superstaq/cirq_superstaq/ops/qudit_gates_test.py index 076294893..93aa8308d 100644 --- a/cirq-superstaq/cirq_superstaq/ops/qudit_gates_test.py +++ b/cirq-superstaq/cirq_superstaq/ops/qudit_gates_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import functools diff --git a/cirq-superstaq/cirq_superstaq/sampler.py b/cirq-superstaq/cirq_superstaq/sampler.py index 93d6c3886..46f2a6c1b 100644 --- a/cirq-superstaq/cirq_superstaq/sampler.py +++ b/cirq-superstaq/cirq_superstaq/sampler.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cirq-superstaq/cirq_superstaq/serialization.py b/cirq-superstaq/cirq_superstaq/serialization.py index da13978ae..166e9d5ba 100644 --- a/cirq-superstaq/cirq_superstaq/serialization.py +++ b/cirq-superstaq/cirq_superstaq/serialization.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import importlib.util diff --git a/cirq-superstaq/cirq_superstaq/serialization_test.py b/cirq-superstaq/cirq_superstaq/serialization_test.py index 31fc02411..9fee44cfc 100644 --- a/cirq-superstaq/cirq_superstaq/serialization_test.py +++ b/cirq-superstaq/cirq_superstaq/serialization_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import cirq_superstaq as css diff --git a/cirq-superstaq/cirq_superstaq/service.py b/cirq-superstaq/cirq_superstaq/service.py index 4a8fdc4e9..3a3307c9c 100644 --- a/cirq-superstaq/cirq_superstaq/service.py +++ b/cirq-superstaq/cirq_superstaq/service.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cirq-superstaq/cirq_superstaq/service_test.py b/cirq-superstaq/cirq_superstaq/service_test.py index e9e9068df..006957d1f 100644 --- a/cirq-superstaq/cirq_superstaq/service_test.py +++ b/cirq-superstaq/cirq_superstaq/service_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cirq-superstaq/cirq_superstaq/validation.py b/cirq-superstaq/cirq_superstaq/validation.py index a73b005f3..6f273e9ed 100644 --- a/cirq-superstaq/cirq_superstaq/validation.py +++ b/cirq-superstaq/cirq_superstaq/validation.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from collections.abc import Sequence import cirq diff --git a/cirq-superstaq/cirq_superstaq/validation_test.py b/cirq-superstaq/cirq_superstaq/validation_test.py index 1ea83fc15..365f89288 100644 --- a/cirq-superstaq/cirq_superstaq/validation_test.py +++ b/cirq-superstaq/cirq_superstaq/validation_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import pytest diff --git a/dev_tools/locustfile.py b/dev_tools/locustfile.py index 653e89e18..9553830a5 100644 --- a/dev_tools/locustfile.py +++ b/dev_tools/locustfile.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Locust (https://docs.locust.io/en/stable/what-is-locust.html) is a load testing tool. To run Locust, first install it with "python -m pip install locust", set the SUPERSTAQ_API_KEY environment variable and execute "locust --config=locust.conf" in the "dev_tools" directory. diff --git a/docs/source/conf.py b/docs/source/conf.py index d9bf9eabb..41be15fc1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: diff --git a/general-superstaq/general_superstaq/__init__.py b/general-superstaq/general_superstaq/__init__.py index f80cfe829..731405ae5 100644 --- a/general-superstaq/general_superstaq/__init__.py +++ b/general-superstaq/general_superstaq/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from general_superstaq._init_vars import API_URL, API_VERSION from general_superstaq._version import __version__ from general_superstaq.resource_estimate import ResourceEstimate diff --git a/general-superstaq/general_superstaq/_init_vars.py b/general-superstaq/general_superstaq/_init_vars.py index 4a8fdcb7c..14893fda3 100644 --- a/general-superstaq/general_superstaq/_init_vars.py +++ b/general-superstaq/general_superstaq/_init_vars.py @@ -1,2 +1,15 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. API_URL = "https://superstaq.infleqtion.com" API_VERSION = "v0.2.0" diff --git a/general-superstaq/general_superstaq/_version.py b/general-superstaq/general_superstaq/_version.py index c0c3de5be..df49af36b 100644 --- a/general-superstaq/general_superstaq/_version.py +++ b/general-superstaq/general_superstaq/_version.py @@ -1 +1,14 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. __version__ = "0.5.20" diff --git a/general-superstaq/general_superstaq/_version_test.py b/general-superstaq/general_superstaq/_version_test.py index 6a74b873c..43717f533 100644 --- a/general-superstaq/general_superstaq/_version_test.py +++ b/general-superstaq/general_superstaq/_version_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import packaging.version import general_superstaq as gss diff --git a/general-superstaq/general_superstaq/check/__init__.py b/general-superstaq/general_superstaq/check/__init__.py index a75bf9464..bfde1ccae 100644 --- a/general-superstaq/general_superstaq/check/__init__.py +++ b/general-superstaq/general_superstaq/check/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from checks_superstaq import ( # To be removed in version 0.5.0 __version__, all_, diff --git a/general-superstaq/general_superstaq/resource_estimate.py b/general-superstaq/general_superstaq/resource_estimate.py index 25819c8c2..a8d7638ab 100644 --- a/general-superstaq/general_superstaq/resource_estimate.py +++ b/general-superstaq/general_superstaq/resource_estimate.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from dataclasses import InitVar, dataclass diff --git a/general-superstaq/general_superstaq/resource_estimate_test.py b/general-superstaq/general_superstaq/resource_estimate_test.py index d71651a17..50466d663 100644 --- a/general-superstaq/general_superstaq/resource_estimate_test.py +++ b/general-superstaq/general_superstaq/resource_estimate_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from general_superstaq import ResourceEstimate diff --git a/general-superstaq/general_superstaq/serialization.py b/general-superstaq/general_superstaq/serialization.py index b00fd7c50..de972c914 100644 --- a/general-superstaq/general_superstaq/serialization.py +++ b/general-superstaq/general_superstaq/serialization.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import codecs import pickle from typing import Any diff --git a/general-superstaq/general_superstaq/serialization_test.py b/general-superstaq/general_superstaq/serialization_test.py index 6431ca2c6..0e790e48a 100644 --- a/general-superstaq/general_superstaq/serialization_test.py +++ b/general-superstaq/general_superstaq/serialization_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import general_superstaq as gss diff --git a/general-superstaq/general_superstaq/service.py b/general-superstaq/general_superstaq/service.py index 494457b2f..067b646ae 100644 --- a/general-superstaq/general_superstaq/service.py +++ b/general-superstaq/general_superstaq/service.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import numbers diff --git a/general-superstaq/general_superstaq/service_test.py b/general-superstaq/general_superstaq/service_test.py index 96848fe46..8ba173a29 100644 --- a/general-superstaq/general_superstaq/service_test.py +++ b/general-superstaq/general_superstaq/service_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import os diff --git a/general-superstaq/general_superstaq/superstaq_client.py b/general-superstaq/general_superstaq/superstaq_client.py index 8ee0785d0..2001f052d 100644 --- a/general-superstaq/general_superstaq/superstaq_client.py +++ b/general-superstaq/general_superstaq/superstaq_client.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/superstaq_client_test.py b/general-superstaq/general_superstaq/superstaq_client_test.py index 697cf49a8..eee0df903 100644 --- a/general-superstaq/general_superstaq/superstaq_client_test.py +++ b/general-superstaq/general_superstaq/superstaq_client_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/superstaq_exceptions.py b/general-superstaq/general_superstaq/superstaq_exceptions.py index 9a10d3cef..f43a7210f 100644 --- a/general-superstaq/general_superstaq/superstaq_exceptions.py +++ b/general-superstaq/general_superstaq/superstaq_exceptions.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Exceptions for the Superstaq API.""" diff --git a/general-superstaq/general_superstaq/superstaq_exceptions_test.py b/general-superstaq/general_superstaq/superstaq_exceptions_test.py index b9367a309..e970e6a0c 100644 --- a/general-superstaq/general_superstaq/superstaq_exceptions_test.py +++ b/general-superstaq/general_superstaq/superstaq_exceptions_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developers +# Copyright 2021 The Cirq Developer, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/testing.py b/general-superstaq/general_superstaq/testing.py index 74732fdc6..b729578ff 100644 --- a/general-superstaq/general_superstaq/testing.py +++ b/general-superstaq/general_superstaq/testing.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from general_superstaq.typing import Target TARGET_LIST = { diff --git a/general-superstaq/general_superstaq/typing.py b/general-superstaq/general_superstaq/typing.py index 3724bf0f1..26cb4254e 100644 --- a/general-superstaq/general_superstaq/typing.py +++ b/general-superstaq/general_superstaq/typing.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from typing import Any, TypedDict diff --git a/general-superstaq/general_superstaq/validation.py b/general-superstaq/general_superstaq/validation.py index 879cb57f4..ca399ca9c 100644 --- a/general-superstaq/general_superstaq/validation.py +++ b/general-superstaq/general_superstaq/validation.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import numbers diff --git a/general-superstaq/general_superstaq/validation_test.py b/general-superstaq/general_superstaq/validation_test.py index 9963a151c..2ed59b010 100644 --- a/general-superstaq/general_superstaq/validation_test.py +++ b/general-superstaq/general_superstaq/validation_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import re diff --git a/qiskit-superstaq/qiskit_superstaq/__init__.py b/qiskit-superstaq/qiskit_superstaq/__init__.py index 8bc58fba3..331cd8c86 100644 --- a/qiskit-superstaq/qiskit_superstaq/__init__.py +++ b/qiskit-superstaq/qiskit_superstaq/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from . import compiler_output, custom_gates, serialization, validation from ._version import __version__ from .compiler_output import active_qubit_indices, classical_bit_mapping, measured_qubit_indices diff --git a/qiskit-superstaq/qiskit_superstaq/_version_test.py b/qiskit-superstaq/qiskit_superstaq/_version_test.py index d76b228b2..94a183867 100644 --- a/qiskit-superstaq/qiskit_superstaq/_version_test.py +++ b/qiskit-superstaq/qiskit_superstaq/_version_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import packaging.version import qiskit_superstaq as qss diff --git a/qiskit-superstaq/qiskit_superstaq/compiler_output.py b/qiskit-superstaq/qiskit_superstaq/compiler_output.py index 9d7da46b3..c0ad97e3d 100644 --- a/qiskit-superstaq/qiskit_superstaq/compiler_output.py +++ b/qiskit-superstaq/qiskit_superstaq/compiler_output.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import importlib.util diff --git a/qiskit-superstaq/qiskit_superstaq/compiler_output_test.py b/qiskit-superstaq/qiskit_superstaq/compiler_output_test.py index 333aafc9a..b56b9123e 100644 --- a/qiskit-superstaq/qiskit_superstaq/compiler_output_test.py +++ b/qiskit-superstaq/qiskit_superstaq/compiler_output_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import importlib diff --git a/qiskit-superstaq/qiskit_superstaq/conftest.py b/qiskit-superstaq/qiskit_superstaq/conftest.py index bc45d8f86..4c1aefcfc 100644 --- a/qiskit-superstaq/qiskit_superstaq/conftest.py +++ b/qiskit-superstaq/qiskit_superstaq/conftest.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import general_superstaq as gss diff --git a/qiskit-superstaq/qiskit_superstaq/custom_gates.py b/qiskit-superstaq/qiskit_superstaq/custom_gates.py index e045e787e..38131b871 100644 --- a/qiskit-superstaq/qiskit_superstaq/custom_gates.py +++ b/qiskit-superstaq/qiskit_superstaq/custom_gates.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import functools diff --git a/qiskit-superstaq/qiskit_superstaq/custom_gates_test.py b/qiskit-superstaq/qiskit_superstaq/custom_gates_test.py index 07fab4dd0..a9c56abe1 100644 --- a/qiskit-superstaq/qiskit_superstaq/custom_gates_test.py +++ b/qiskit-superstaq/qiskit_superstaq/custom_gates_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import numpy as np diff --git a/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py b/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py index d12ec8efe..491c4e5f0 100644 --- a/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py +++ b/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Integration checks that run daily (via Github action) between client and prod server.""" from __future__ import annotations diff --git a/qiskit-superstaq/qiskit_superstaq/serialization.py b/qiskit-superstaq/qiskit_superstaq/serialization.py index d99bd5a58..8e109eaac 100644 --- a/qiskit-superstaq/qiskit_superstaq/serialization.py +++ b/qiskit-superstaq/qiskit_superstaq/serialization.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import io diff --git a/qiskit-superstaq/qiskit_superstaq/serialization_test.py b/qiskit-superstaq/qiskit_superstaq/serialization_test.py index 0e3febc28..e7956ca23 100644 --- a/qiskit-superstaq/qiskit_superstaq/serialization_test.py +++ b/qiskit-superstaq/qiskit_superstaq/serialization_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import io diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py b/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py index 16168bae7..4bddfbcdf 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2021. +# (C) Copyright IBM 2021, 2024 Infleqtion. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_backend_test.py b/qiskit-superstaq/qiskit_superstaq/superstaq_backend_test.py index 6a125a045..ee6ac78f1 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_backend_test.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_backend_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import json diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_job.py b/qiskit-superstaq/qiskit_superstaq/superstaq_job.py index 5f4e2592b..45e998b2d 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_job.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_job.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2021. +# (C) Copyright IBM 2021, 2024 Infleqtion. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_job_test.py b/qiskit-superstaq/qiskit_superstaq/superstaq_job_test.py index 0201cabf8..12ad67c2e 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_job_test.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_job_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from typing import TYPE_CHECKING diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py b/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py index 657fcbe47..137fe8e6f 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2021. +# (C) Copyright IBM 2021, 2024 Infleqtion. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py b/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py index 3b645db05..d58844b9f 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import json diff --git a/qiskit-superstaq/qiskit_superstaq/validation.py b/qiskit-superstaq/qiskit_superstaq/validation.py index 346bf3e4b..c9ebb3eac 100644 --- a/qiskit-superstaq/qiskit_superstaq/validation.py +++ b/qiskit-superstaq/qiskit_superstaq/validation.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from collections.abc import Sequence import qiskit diff --git a/qiskit-superstaq/qiskit_superstaq/validation_test.py b/qiskit-superstaq/qiskit_superstaq/validation_test.py index c8690b84d..2f0f1a676 100644 --- a/qiskit-superstaq/qiskit_superstaq/validation_test.py +++ b/qiskit-superstaq/qiskit_superstaq/validation_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import pytest import qiskit diff --git a/supermarq-benchmarks/supermarq/__init__.py b/supermarq-benchmarks/supermarq/__init__.py index 3500c83d0..af16db623 100644 --- a/supermarq-benchmarks/supermarq/__init__.py +++ b/supermarq-benchmarks/supermarq/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from . import benchmark, converters, features, plotting, simulation, stabilizers from ._version import __version__ from .benchmarks import ( diff --git a/supermarq-benchmarks/supermarq/_version_test.py b/supermarq-benchmarks/supermarq/_version_test.py index 4489063e1..bf520dc47 100644 --- a/supermarq-benchmarks/supermarq/_version_test.py +++ b/supermarq-benchmarks/supermarq/_version_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import packaging.version import supermarq diff --git a/supermarq-benchmarks/supermarq/benchmark.py b/supermarq-benchmarks/supermarq/benchmark.py index 5ae424b3c..f1f3a98ea 100644 --- a/supermarq-benchmarks/supermarq/benchmark.py +++ b/supermarq-benchmarks/supermarq/benchmark.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import abc diff --git a/supermarq-benchmarks/supermarq/benchmark_test.py b/supermarq-benchmarks/supermarq/benchmark_test.py index 682add8ec..bf5e2966a 100644 --- a/supermarq-benchmarks/supermarq/benchmark_test.py +++ b/supermarq-benchmarks/supermarq/benchmark_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Mapping diff --git a/supermarq-benchmarks/supermarq/benchmarks/__init__.py b/supermarq-benchmarks/supermarq/benchmarks/__init__.py index acbb6dc54..686d50230 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/__init__.py +++ b/supermarq-benchmarks/supermarq/benchmarks/__init__.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from . import ( bit_code, ghz, diff --git a/supermarq-benchmarks/supermarq/benchmarks/bit_code.py b/supermarq-benchmarks/supermarq/benchmarks/bit_code.py index 883a4c1e8..21692a46b 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/bit_code.py +++ b/supermarq-benchmarks/supermarq/benchmarks/bit_code.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Iterator diff --git a/supermarq-benchmarks/supermarq/benchmarks/bit_code_test.py b/supermarq-benchmarks/supermarq/benchmarks/bit_code_test.py index 1f6903e73..8a537a1f2 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/bit_code_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/bit_code_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from typing import cast diff --git a/supermarq-benchmarks/supermarq/benchmarks/ghz.py b/supermarq-benchmarks/supermarq/benchmarks/ghz.py index c9e470a56..ea3de78dd 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/ghz.py +++ b/supermarq-benchmarks/supermarq/benchmarks/ghz.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Iterator diff --git a/supermarq-benchmarks/supermarq/benchmarks/ghz_test.py b/supermarq-benchmarks/supermarq/benchmarks/ghz_test.py index 6bdc1e508..9d99c3361 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/ghz_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/ghz_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import numpy as np import pytest diff --git a/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation.py b/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation.py index 6d86ef497..d0707d490 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation.py +++ b/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Mapping diff --git a/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation_test.py b/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation_test.py index b5e5c0485..e51293d48 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/hamiltonian_simulation_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import supermarq from supermarq.benchmarks.hamiltonian_simulation import HamiltonianSimulation diff --git a/supermarq-benchmarks/supermarq/benchmarks/mermin_bell.py b/supermarq-benchmarks/supermarq/benchmarks/mermin_bell.py index 8e63f2659..f29250440 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/mermin_bell.py +++ b/supermarq-benchmarks/supermarq/benchmarks/mermin_bell.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import itertools diff --git a/supermarq-benchmarks/supermarq/benchmarks/mermin_bell_test.py b/supermarq-benchmarks/supermarq/benchmarks/mermin_bell_test.py index 0b0e83c36..386584cbd 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/mermin_bell_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/mermin_bell_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from unittest.mock import patch import qiskit diff --git a/supermarq-benchmarks/supermarq/benchmarks/phase_code.py b/supermarq-benchmarks/supermarq/benchmarks/phase_code.py index 9fa41c4a8..29000965e 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/phase_code.py +++ b/supermarq-benchmarks/supermarq/benchmarks/phase_code.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Iterator diff --git a/supermarq-benchmarks/supermarq/benchmarks/phase_code_test.py b/supermarq-benchmarks/supermarq/benchmarks/phase_code_test.py index 14be23e8d..5eff07d02 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/phase_code_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/phase_code_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from typing import cast diff --git a/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy.py b/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy.py index 7cacee776..aa905f57e 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy.py +++ b/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Definition of the Fermionic SWAP QAOA benchmark within the Supermarq suite.""" from __future__ import annotations diff --git a/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy_test.py b/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy_test.py index 547cfe6cc..6d2ecb531 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/qaoa_fermionic_swap_proxy_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import supermarq diff --git a/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy.py b/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy.py index 567cec638..2c50b7dd2 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy.py +++ b/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Mapping diff --git a/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy_test.py b/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy_test.py index 6208447d4..29556f970 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/qaoa_vanilla_proxy_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import supermarq diff --git a/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy.py b/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy.py index c9a8a4677..da1f1fea2 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy.py +++ b/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import copy diff --git a/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy_test.py b/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy_test.py index 6b39e1ae1..0838d8331 100644 --- a/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy_test.py +++ b/supermarq-benchmarks/supermarq/benchmarks/vqe_proxy_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import supermarq from supermarq.benchmarks.vqe_proxy import VQEProxy diff --git a/supermarq-benchmarks/supermarq/converters.py b/supermarq-benchmarks/supermarq/converters.py index 9d3176d5c..1cec4e36e 100644 --- a/supermarq-benchmarks/supermarq/converters.py +++ b/supermarq-benchmarks/supermarq/converters.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import networkx as nx import numpy as np diff --git a/supermarq-benchmarks/supermarq/converters_test.py b/supermarq-benchmarks/supermarq/converters_test.py index ba37084bc..72f3d6686 100644 --- a/supermarq-benchmarks/supermarq/converters_test.py +++ b/supermarq-benchmarks/supermarq/converters_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import qiskit diff --git a/supermarq-benchmarks/supermarq/features.py b/supermarq-benchmarks/supermarq/features.py index 73702d9c3..4009d3a95 100644 --- a/supermarq-benchmarks/supermarq/features.py +++ b/supermarq-benchmarks/supermarq/features.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import supermarq diff --git a/supermarq-benchmarks/supermarq/features_test.py b/supermarq-benchmarks/supermarq/features_test.py index f2736ef68..8abbdc82a 100644 --- a/supermarq-benchmarks/supermarq/features_test.py +++ b/supermarq-benchmarks/supermarq/features_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import cirq import supermarq diff --git a/supermarq-benchmarks/supermarq/plotting.py b/supermarq-benchmarks/supermarq/plotting.py index 282141cd3..a3c535c28 100644 --- a/supermarq-benchmarks/supermarq/plotting.py +++ b/supermarq-benchmarks/supermarq/plotting.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations from collections.abc import Iterable diff --git a/supermarq-benchmarks/supermarq/plotting_test.py b/supermarq-benchmarks/supermarq/plotting_test.py index 1760d3587..5bd63420c 100644 --- a/supermarq-benchmarks/supermarq/plotting_test.py +++ b/supermarq-benchmarks/supermarq/plotting_test.py @@ -1,4 +1,17 @@ # pylint: disable=missing-function-docstring,missing-class-docstring +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import supermarq diff --git a/supermarq-benchmarks/supermarq/simulation.py b/supermarq-benchmarks/supermarq/simulation.py index 17a134c44..b603654c9 100644 --- a/supermarq-benchmarks/supermarq/simulation.py +++ b/supermarq-benchmarks/supermarq/simulation.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import cirq diff --git a/supermarq-benchmarks/supermarq/stabilizers.py b/supermarq-benchmarks/supermarq/stabilizers.py index 5bb2d7ff1..04fbd00c1 100644 --- a/supermarq-benchmarks/supermarq/stabilizers.py +++ b/supermarq-benchmarks/supermarq/stabilizers.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from __future__ import annotations import copy From 3fa1d1c40b55fc1539f2c1ed63cccf94b6ea39e8 Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:45:12 -0500 Subject: [PATCH 11/25] Fix bug with appending Infleqtion to apache license --- checks-superstaq/checks_superstaq/license_header_format_.py | 5 ++++- cirq-superstaq/cirq_superstaq/__init__.py | 2 +- cirq-superstaq/cirq_superstaq/job.py | 2 +- cirq-superstaq/cirq_superstaq/job_test.py | 2 +- cirq-superstaq/cirq_superstaq/sampler.py | 2 +- cirq-superstaq/cirq_superstaq/service.py | 2 +- cirq-superstaq/cirq_superstaq/service_test.py | 2 +- general-superstaq/general_superstaq/superstaq_client.py | 2 +- general-superstaq/general_superstaq/superstaq_client_test.py | 2 +- .../general_superstaq/superstaq_exceptions_test.py | 2 +- 10 files changed, 13 insertions(+), 10 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 442cdb8b7..47aa8948e 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -181,8 +181,11 @@ def _append_to_header(file: str, license_header: LicenseHeader) -> None: ): if line[-2] == ",": prepend += line[:-1] + " 2024 Infleqtion.\n" + break + if line[-2].isalpha(): + prepend += line[:-1] + ", 2024 Infleqtion.\n" else: - prepend += line[:-2] + ", 2024 Infleqtion.\n" + prepend += line[:-2] + " 2024 Infleqtion.\n" break prepend += line diff --git a/cirq-superstaq/cirq_superstaq/__init__.py b/cirq-superstaq/cirq_superstaq/__init__.py index d92c111e8..912bbe23d 100644 --- a/cirq-superstaq/cirq_superstaq/__init__.py +++ b/cirq-superstaq/cirq_superstaq/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/job.py b/cirq-superstaq/cirq_superstaq/job.py index b05b09618..a2a6e3957 100644 --- a/cirq-superstaq/cirq_superstaq/job.py +++ b/cirq-superstaq/cirq_superstaq/job.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/job_test.py b/cirq-superstaq/cirq_superstaq/job_test.py index ac1d98fdb..6b803346f 100644 --- a/cirq-superstaq/cirq_superstaq/job_test.py +++ b/cirq-superstaq/cirq_superstaq/job_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cirq-superstaq/cirq_superstaq/sampler.py b/cirq-superstaq/cirq_superstaq/sampler.py index 46f2a6c1b..6401fc7dc 100644 --- a/cirq-superstaq/cirq_superstaq/sampler.py +++ b/cirq-superstaq/cirq_superstaq/sampler.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cirq-superstaq/cirq_superstaq/service.py b/cirq-superstaq/cirq_superstaq/service.py index 3a3307c9c..25fb7a037 100644 --- a/cirq-superstaq/cirq_superstaq/service.py +++ b/cirq-superstaq/cirq_superstaq/service.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cirq-superstaq/cirq_superstaq/service_test.py b/cirq-superstaq/cirq_superstaq/service_test.py index 006957d1f..656b42978 100644 --- a/cirq-superstaq/cirq_superstaq/service_test.py +++ b/cirq-superstaq/cirq_superstaq/service_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/superstaq_client.py b/general-superstaq/general_superstaq/superstaq_client.py index 2001f052d..30d6bf481 100644 --- a/general-superstaq/general_superstaq/superstaq_client.py +++ b/general-superstaq/general_superstaq/superstaq_client.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/superstaq_client_test.py b/general-superstaq/general_superstaq/superstaq_client_test.py index eee0df903..91ba71a0f 100644 --- a/general-superstaq/general_superstaq/superstaq_client_test.py +++ b/general-superstaq/general_superstaq/superstaq_client_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/general-superstaq/general_superstaq/superstaq_exceptions_test.py b/general-superstaq/general_superstaq/superstaq_exceptions_test.py index e970e6a0c..87b11a9af 100644 --- a/general-superstaq/general_superstaq/superstaq_exceptions_test.py +++ b/general-superstaq/general_superstaq/superstaq_exceptions_test.py @@ -1,4 +1,4 @@ -# Copyright 2021 The Cirq Developer, 2024 Infleqtion. +# Copyright 2021 The Cirq Developers, 2024 Infleqtion. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at From 572799888a98e6ba4d40f7890883fd11ae8cb73e Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 16 Jul 2024 17:46:13 -0500 Subject: [PATCH 12/25] Fix bug with appending Infleqtion to apache license --- checks-superstaq/checks_superstaq/license_header_format_.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 47aa8948e..42fd26e0e 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -181,11 +181,10 @@ def _append_to_header(file: str, license_header: LicenseHeader) -> None: ): if line[-2] == ",": prepend += line[:-1] + " 2024 Infleqtion.\n" - break - if line[-2].isalpha(): + elif line[-2].isalpha(): prepend += line[:-1] + ", 2024 Infleqtion.\n" else: - prepend += line[:-2] + " 2024 Infleqtion.\n" + prepend += line[:-2] + ", 2024 Infleqtion.\n" break prepend += line From 6645aa802ac0a3820364d4762a178032df3a86e5 Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 10:40:31 -0500 Subject: [PATCH 13/25] Implement suggested changes --- .../checks_superstaq/checks-pyproject.toml | 4 + .../license_header_format_.py | 182 ++++++++++++------ 2 files changed, 130 insertions(+), 56 deletions(-) diff --git a/checks-superstaq/checks_superstaq/checks-pyproject.toml b/checks-superstaq/checks_superstaq/checks-pyproject.toml index 773cbe840..f8bcf24fb 100644 --- a/checks-superstaq/checks_superstaq/checks-pyproject.toml +++ b/checks-superstaq/checks_superstaq/checks-pyproject.toml @@ -13,6 +13,10 @@ license_header = """# Copyright 2024 Infleqtion # See the License for the specific language governing permissions and # limitations under the License. """ +license_name = "Apache" +licensee = "Infleqtion" +editable = true + # Check script configuration: [tool.pytest.ini_options] diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 42fd26e0e..f6d6c1c4d 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -16,6 +16,7 @@ from __future__ import annotations +import dataclasses import enum import re import sys @@ -28,18 +29,54 @@ from checks_superstaq import check_utils -# The license header that should be added to the files with no license headers is read from -# the pyproject.toml file. It should be under [tool.license_header_format] assigned to the variable -# license_header -try: + +def read_toml() -> tuple[str, str, str, bool] | None: + """Reads the pyproject.toml file to get license information. Fields should be under + [tool.license_header_format] and named `license_header`, `license_name`, `licensee` and + `editable`. + + Returns tuple containing the exptected license header, license name, license owner, and + whether similar licenses are editable. + """ + data: dict[str, Any] = tomlkit.parse(Path("pyproject.toml").read_text()) - expected_license_header = str(data["tool"]["license_header_format"]["license_header"]) - in_server = "Apache" not in expected_license_header -except KeyError: - raise KeyError( - "Under [tool.license_header_format] add a license_header field with the license\ - heder that should be added to source code files in the repository." - ) + try: + expected_license_header = str(data["tool"]["license_header_format"]["license_header"]) + except KeyError: + print( + "Under [tool.license_header_format] add a `license_header` field filled with the license" + " header that should be added to source code files in the repository." + ) + return + + try: + license_name = str(data["tool"]["license_header_format"]["license_name"]) + except KeyError: + print( + "Under [tool.license_header_format] add a `license_name` field filled with the" + " license's name." + ) + return + + try: + licensee = str(data["tool"]["license_header_format"]["licensee"]) + except KeyError: + print( + "Under [tool.license_header_format] add a `licensee` field filled with the " + " name of the licensee." + ) + return + + try: + editable = bool(data["tool"]["license_header_format"]["editable"]) + except KeyError: + print( + "Under [tool.license_header_format] add an `editable` boolean field set to True if the" + " license owner can be appended to similar license and False otherwise." + ) + return + + return expected_license_header, license_name, licensee, editable class HeaderType(enum.Enum): @@ -52,36 +89,28 @@ class HeaderType(enum.Enum): """ VALID = 1 - OTHER_APACHE = 2 + SIMILAR_LICENSE = 2 OUTDATED = 3 OTHER = 4 +@dataclasses.dataclass class LicenseHeader: """Class to describe license headers found in files including the header itself, the line numbers where it is found in a file, and the type of the license header.""" - def __init__(self, start_line_num: int) -> None: - self.start_line_num = start_line_num - self.license_header = "" - self.end_line_num = 0 - - @property - def header_type(self) -> HeaderType: - """Returns the type of the license header.""" - return self._header_type - - @header_type.setter - def header_type(self, header_type: HeaderType) -> None: - """Sets the type of the license header.""" - self._header_type = header_type + start_line_num: int + header_type: HeaderType | None = None + end_line_num: int = 0 + license_header: str = "" def __str__(self) -> str: """The string representation of a license header used later for printing.""" - return f""" - Beginning at line: {self.start_line_num} - Ending at line : {self.end_line_num}\n -{self.license_header}\n""" + return ( + f"Beginning at line: {self.start_line_num}\n" + f"Ending at line : {self.end_line_num}\n\n" + f"{self.license_header}\n" + ) def _extract_license_header(file: str) -> list[LicenseHeader]: @@ -100,7 +129,7 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: license_header = "" exceptions = ["# pylint:", "#!/", "# mypy:"] - with open(file, "r+") as f: + with open(file, "r") as f: for line_num, line in enumerate(f): if not license_header and line[0] == "\n": continue @@ -129,44 +158,58 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: return license_header_lst -def _validate_license_header(license_header_lst: list[LicenseHeader]) -> bool: +def _validate_license_header( + license_header_lst: list[LicenseHeader], licensee: str, license_name: str, editable: bool +) -> bool: """Returns whether there is a valid Infleqtion license header in a file and for each license header in a file, it assigns each theiir type. - VALID: if the header contains a Copyright Infleqtion line. - OUTDATED: if the header is for ColdQuanta Inc. - - OTHER_APACHE: if the header is an Apache license but not from Infleqtion + - SIMILAR_LICENSE: if the header is license but not from Infleqtion for client-superstaq. - OTHER: if the header is any other one. Also includes Apache license headers for server-superstaq. Args: license_header_lst: List of the license_header objects for each header in a file. + licensee: The owner of the expected license. + license_name: The name of the expected license. + editable: Whether similar licenses can be edited to include the license owner instead + adding the entire license to the file. Returns: Whether there is a valid license header in a file or not. """ - valid_header_regex = re.compile(r"(.*)Copyright(.*)Infleqtion") - outdated_header_regex = re.compile(r"(.*)Copyright(.*)ColdQuanta Inc\.") + valid_header_regex = re.compile(rf"(.*)Copyright(.*){licensee}") + outdated_header_regex = re.compile( + r"(.*)Copyright(.*)ColdQuanta Inc\." + ) # remove after first iteration valid = False for license_header in license_header_lst: - if re.search(outdated_header_regex, license_header.license_header): - license_header.header_type = HeaderType.OUTDATED - elif re.search(valid_header_regex, license_header.license_header): + if ( + re.search(valid_header_regex, license_header.license_header) + and license_name in license_header.license_header + ): license_header.header_type = HeaderType.VALID valid = True - elif in_server or "Apache" not in license_header.license_header: + elif re.search( + outdated_header_regex, license_header.license_header + ): # replace with re.search(valid_header_regex, license_header.license_header) and license_name not in license_header.license_header + license_header.header_type = HeaderType.OUTDATED + elif not editable or license_name not in license_header.license_header: license_header.header_type = HeaderType.OTHER else: - license_header.header_type = HeaderType.OTHER_APACHE + license_header.header_type = HeaderType.SIMILAR_LICENSE return valid -def _append_to_header(file: str, license_header: LicenseHeader) -> None: +def _append_to_header(file: str, license_header: LicenseHeader, licensee: str) -> None: """Appends Infleqtion to existing Apache license that is not from Infleqtion. Args: file: The name/path for the file whose license header will have Infleqtion added to it. license_header: The specific license header that Infleqtion is being appended to. + licensee: The licensee of the target license header. Returns nothing. """ @@ -180,11 +223,11 @@ def _append_to_header(file: str, license_header: LicenseHeader) -> None: and license_header.start_line_num <= line_num + 1 < license_header.end_line_num ): if line[-2] == ",": - prepend += line[:-1] + " 2024 Infleqtion.\n" + prepend += line[:-1] + " 2024 {licensee}.\n" elif line[-2].isalpha(): - prepend += line[:-1] + ", 2024 Infleqtion.\n" + prepend += line[:-1] + ", 2024 {licensee}.\n" else: - prepend += line[:-2] + ", 2024 Infleqtion.\n" + prepend += line[:-2] + ", 2024 {licensee}.\n" break prepend += line @@ -223,11 +266,12 @@ def _remove_header(file: str, license_header: LicenseHeader) -> None: f.truncate() -def _add_license_header(file: str) -> None: +def _add_license_header(file: str, expected_license_header: str) -> None: """Adds the correct license header to a file. Args: file: The file name/path to which license header is added. + expected_license_header: The target license header. Returns nothing. """ @@ -257,6 +301,7 @@ def handle_bad_header( valid: bool, silent: bool, append_flag: bool, + licensee: str, ) -> bool: """Function handles bad headers in files. The cases are handled according to the HeaderType: - VALID and OTHER: no change. @@ -271,10 +316,11 @@ def handle_bad_header( valid: Whether there is a valid header in the file. silent: Whether to print out any incorrect license headers that have been found. append_flag: Whether Infleqtion has already been appended to an Apache License in the file. + licensee: The owner of the expected license. Returns the updated append_flag. """ - if license_header.header_type == HeaderType.OTHER_APACHE: + if license_header.header_type == HeaderType.SIMILAR_LICENSE: if not valid and not silent and not apply: print("----------") print(check_utils.warning(str(license_header))) @@ -282,7 +328,7 @@ def handle_bad_header( # don't append Infleqtion to Apache license if there is a valid Infleqtion # license header already or it has already been appended to a license. if not append_flag and apply and not valid: - _append_to_header(file, license_header) + _append_to_header(file, license_header, licensee) append_flag = True print(f"{styled_file_name}: {check_utils.success('License header fixed.')}") elif license_header.header_type == HeaderType.OUTDATED: @@ -301,7 +347,17 @@ def handle_bad_header( return append_flag -def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_header: bool) -> int: +def run_checker( + file: str, + apply: bool, + silent: bool, + no_header: bool, + bad_header: bool, + expected_license_header: str, + license_name: str, + licensee: str, + editable: bool, +) -> int: """For a given file, checks if it has the correct license header. If apply is set to True, it removes any bad license headers that have been found and replaces them with the correct license header. @@ -312,28 +368,33 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade silent: Whether to print out any incorrect license headers that have been found. no_header: Whether to only handle files with no license headers. bad_header: Whether to only handle files with incorrect headers. + expected_license_header: The target license header. + license_name: The name of the expected license. + licensee: The owner of the expected license. + editable: Whether similar licenses can be edited to include the license owner instead + adding the entire license to the file. Returns the exit code. 1 if an incorrect or no license header is found. 0 if correct. """ + license_header_lst: list[LicenseHeader] = _extract_license_header(file) styled_file_name = check_utils.styled(file, check_utils.Style.BOLD) if len(license_header_lst) == 0: if (not no_header and not bad_header) or no_header: if apply: - _add_license_header(file) + _add_license_header(file, expected_license_header) print(f"{styled_file_name}: {check_utils.success('License header added.')}") else: print(f"{styled_file_name}: {check_utils.warning('No license header found.')}") return 1 else: return 0 - # return handle_no_header(file, apply, no_header, bad_header) if no_header and not bad_header: # if the --no-header flag is set return 0 - valid = _validate_license_header(license_header_lst) + valid = _validate_license_header(license_header_lst, licensee, license_name, editable) append_flag = False # used to make sure Infleqtion is not appended to multiple Apace headers exit_code = 0 @@ -353,10 +414,11 @@ def run_checker(file: str, apply: bool, silent: bool, no_header: bool, bad_heade valid, silent, append_flag, + licensee, ) if not valid and not append_flag and apply: - _add_license_header(file) + _add_license_header(file, expected_license_header) print(f"{styled_file_name}: {check_utils.success('License header added.')}") return exit_code @@ -388,7 +450,9 @@ def run( """ ) parser.add_argument( - "--apply", action="store_true", help="Add the license header to files.", default=False + "--apply", + action="store_true", + help="Add the license header to files.", ) target_case = parser.add_mutually_exclusive_group() @@ -396,19 +460,16 @@ def run( "--no-header", action="store_true", help="Hanlde only files with no license header.", - default=False, ) target_case.add_argument( "--bad-header", action="store_true", help="Handle only files with incorrect license headers.", - default=False, ) parser.add_argument( "--silent", action="store_true", help="Do not show incorrect license headers.", - default=False, ) parsed_args, _ = parser.parse_known_intermixed_args(args) @@ -420,6 +481,11 @@ def run( print("No files selected.\n") return 0 + if (toml_data := read_toml()) is not None: + expected_license_header, licensee, license_name, editable = toml_data + else: + return 0 + exit_code = 0 for file in files: exit_code += run_checker( @@ -428,6 +494,10 @@ def run( parsed_args.silent or silent, parsed_args.no_header, parsed_args.bad_header, + expected_license_header, + licensee, + license_name, + editable, ) if not exit_code: From 939ff01bb9d487043e0111a26706089c73f5cb6a Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 11:00:14 -0500 Subject: [PATCH 14/25] Add license header --- .../checks_superstaq/pylint_import_annotations.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/checks-superstaq/checks_superstaq/pylint_import_annotations.py b/checks-superstaq/checks_superstaq/pylint_import_annotations.py index 1a5aeab9a..8de5b26f6 100644 --- a/checks-superstaq/checks_superstaq/pylint_import_annotations.py +++ b/checks-superstaq/checks_superstaq/pylint_import_annotations.py @@ -1,3 +1,16 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Check for whether python file has from __future__ import annotations as the first import.""" from __future__ import annotations From 47b377161b6e05a75b1a6a4a8c66da46dd03691b Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 11:17:24 -0500 Subject: [PATCH 15/25] Edit docstrings and minor fixes --- .../license_header_format_.py | 70 +++++++++---------- checks/license_header_format_.py | 1 + 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index f6d6c1c4d..b877aff8c 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -35,7 +35,8 @@ def read_toml() -> tuple[str, str, str, bool] | None: [tool.license_header_format] and named `license_header`, `license_name`, `licensee` and `editable`. - Returns tuple containing the exptected license header, license name, license owner, and + Returns: + Tuple containing the exptected license header, license name, licensee, and whether similar licenses are editable. """ @@ -44,10 +45,10 @@ def read_toml() -> tuple[str, str, str, bool] | None: expected_license_header = str(data["tool"]["license_header_format"]["license_header"]) except KeyError: print( - "Under [tool.license_header_format] add a `license_header` field filled with the license" - " header that should be added to source code files in the repository." + "Under [tool.license_header_format] add a `license_header` field filled with the" + "license header that should be added to source code files in the repository." ) - return + return None try: license_name = str(data["tool"]["license_header_format"]["license_name"]) @@ -56,7 +57,7 @@ def read_toml() -> tuple[str, str, str, bool] | None: "Under [tool.license_header_format] add a `license_name` field filled with the" " license's name." ) - return + return None try: licensee = str(data["tool"]["license_header_format"]["licensee"]) @@ -65,7 +66,7 @@ def read_toml() -> tuple[str, str, str, bool] | None: "Under [tool.license_header_format] add a `licensee` field filled with the " " name of the licensee." ) - return + return None try: editable = bool(data["tool"]["license_header_format"]["editable"]) @@ -74,7 +75,7 @@ def read_toml() -> tuple[str, str, str, bool] | None: "Under [tool.license_header_format] add an `editable` boolean field set to True if the" " license owner can be appended to similar license and False otherwise." ) - return + return None return expected_license_header, license_name, licensee, editable @@ -82,9 +83,9 @@ def read_toml() -> tuple[str, str, str, bool] | None: class HeaderType(enum.Enum): """Enum used to store the types of licence headers that be found in source code files. - - VALID: valid Infleqtion license header. - - OTHER_APACHE: An Apache license header that is not Infleqtion's. - - OUTDATED: A license belonging to ColdQuanta Inc. + - VALID: valid license header. + - SIMILAR_LICENSE: Matching license type but different licensee. + - OUTDATED: A license belonging to the same licensee but different type than the target. - OTHER: Any other licenses. """ @@ -161,14 +162,12 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: def _validate_license_header( license_header_lst: list[LicenseHeader], licensee: str, license_name: str, editable: bool ) -> bool: - """Returns whether there is a valid Infleqtion license header in a file and for each license + """Returns whether there is a valid license header in a file and for each license header in a file, it assigns each theiir type. - - VALID: if the header contains a Copyright Infleqtion line. - - OUTDATED: if the header is for ColdQuanta Inc. - - SIMILAR_LICENSE: if the header is license but not from Infleqtion - for client-superstaq. - - OTHER: if the header is any other one. Also includes Apache license headers for - server-superstaq. + - VALID: if the header contains a Copyright line. + - OUTDATED: if the header has the correct licensee but different type. + - SIMILAR_LICENSE: if the header is a valid license but not from the licensee. + - OTHER: if the header is any other one. Args: license_header_lst: List of the license_header objects for each header in a file. licensee: The owner of the expected license. @@ -191,9 +190,9 @@ def _validate_license_header( ): license_header.header_type = HeaderType.VALID valid = True - elif re.search( - outdated_header_regex, license_header.license_header - ): # replace with re.search(valid_header_regex, license_header.license_header) and license_name not in license_header.license_header + elif re.search(outdated_header_regex, license_header.license_header): + # replace with re.search(valid_header_regex, license_header.license_header) + # and license_name not in license_header.license_header license_header.header_type = HeaderType.OUTDATED elif not editable or license_name not in license_header.license_header: license_header.header_type = HeaderType.OTHER @@ -204,11 +203,11 @@ def _validate_license_header( def _append_to_header(file: str, license_header: LicenseHeader, licensee: str) -> None: - """Appends Infleqtion to existing Apache license that is not from Infleqtion. + """Appends licensee to existing license header. Args: - file: The name/path for the file whose license header will have Infleqtion added to it. - license_header: The specific license header that Infleqtion is being appended to. + file: The name/path for the file whose license header will have the licensee added to it. + license_header: The specific license header that the licensee is being appended to. licensee: The licensee of the target license header. Returns nothing. @@ -223,11 +222,11 @@ def _append_to_header(file: str, license_header: LicenseHeader, licensee: str) - and license_header.start_line_num <= line_num + 1 < license_header.end_line_num ): if line[-2] == ",": - prepend += line[:-1] + " 2024 {licensee}.\n" + prepend += line[:-1] + f" 2024 {licensee}.\n" elif line[-2].isalpha(): - prepend += line[:-1] + ", 2024 {licensee}.\n" + prepend += line[:-1] + f", 2024 {licensee}.\n" else: - prepend += line[:-2] + ", 2024 {licensee}.\n" + prepend += line[:-2] + f", 2024 {licensee}.\n" break prepend += line @@ -305,7 +304,7 @@ def handle_bad_header( ) -> bool: """Function handles bad headers in files. The cases are handled according to the HeaderType: - VALID and OTHER: no change. - - OTHER_APACHE: the first of this type will have Infleqtion appended to license header. + - SIMILAR_LICENSE: if the header is a valid license but not from the licensee. - OUTDATED: will be removed Args: @@ -315,18 +314,19 @@ def handle_bad_header( apply: Whether to fix the license header if it is incorrect. valid: Whether there is a valid header in the file. silent: Whether to print out any incorrect license headers that have been found. - append_flag: Whether Infleqtion has already been appended to an Apache License in the file. + append_flag: Whether the licensee has already been appended to a header in the file. licensee: The owner of the expected license. - Returns the updated append_flag. + Returns: + The updated append_flag. """ if license_header.header_type == HeaderType.SIMILAR_LICENSE: if not valid and not silent and not apply: print("----------") print(check_utils.warning(str(license_header))) print("----------") - # don't append Infleqtion to Apache license if there is a valid Infleqtion - # license header already or it has already been appended to a license. + # don't append licensee to license header if there is a valid license header already or + # it has already been appended to another license header. if not append_flag and apply and not valid: _append_to_header(file, license_header, licensee) append_flag = True @@ -374,7 +374,8 @@ def run_checker( editable: Whether similar licenses can be edited to include the license owner instead adding the entire license to the file. - Returns the exit code. 1 if an incorrect or no license header is found. 0 if correct. + Returns: + The exit code. 1 if an incorrect or no license header is found. 0 if correct. """ license_header_lst: list[LicenseHeader] = _extract_license_header(file) @@ -395,11 +396,10 @@ def run_checker( return 0 valid = _validate_license_header(license_header_lst, licensee, license_name, editable) - append_flag = False # used to make sure Infleqtion is not appended to multiple Apace headers + append_flag = False # ensure the licensee is not appended to multiple headers exit_code = 0 - # A file has an incorrect license header if it has no valid Infleqtion license header or - # has an outdated ColdQuanta Inc license. + # Incorrect license header if it has no valid license header or has an outdated one. if not valid or any(header.header_type == HeaderType.OUTDATED for header in license_header_lst): exit_code = 1 if not apply: diff --git a/checks/license_header_format_.py b/checks/license_header_format_.py index ef2ef204f..3fe1c5b16 100755 --- a/checks/license_header_format_.py +++ b/checks/license_header_format_.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import annotations import sys From ac45240ae97523091c91a5a00927596e2f809032 Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 11:23:34 -0500 Subject: [PATCH 16/25] fix bad merge --- general-superstaq/general_superstaq/_version.py | 1 - 1 file changed, 1 deletion(-) diff --git a/general-superstaq/general_superstaq/_version.py b/general-superstaq/general_superstaq/_version.py index a0acfb47b..f18633669 100644 --- a/general-superstaq/general_superstaq/_version.py +++ b/general-superstaq/general_superstaq/_version.py @@ -11,5 +11,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.5.20" __version__ = "0.5.21" From 3e17822250e351d5633f769c5886694bed19f937 Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 11:35:03 -0500 Subject: [PATCH 17/25] Remove check for outdated license --- .../checks_superstaq/license_header_format_.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index b877aff8c..392176e67 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -178,9 +178,6 @@ def _validate_license_header( Returns: Whether there is a valid license header in a file or not. """ valid_header_regex = re.compile(rf"(.*)Copyright(.*){licensee}") - outdated_header_regex = re.compile( - r"(.*)Copyright(.*)ColdQuanta Inc\." - ) # remove after first iteration valid = False for license_header in license_header_lst: @@ -190,9 +187,10 @@ def _validate_license_header( ): license_header.header_type = HeaderType.VALID valid = True - elif re.search(outdated_header_regex, license_header.license_header): - # replace with re.search(valid_header_regex, license_header.license_header) - # and license_name not in license_header.license_header + elif ( + re.search(valid_header_regex, license_header.license_header) + and license_name not in license_header.license_header + ): license_header.header_type = HeaderType.OUTDATED elif not editable or license_name not in license_header.license_header: license_header.header_type = HeaderType.OTHER From d2207c7dedf626fffefb7c5ddab024aaff32a9be Mon Sep 17 00:00:00 2001 From: nati Date: Mon, 5 Aug 2024 13:02:56 -0500 Subject: [PATCH 18/25] wildcard approach --- .../checks_superstaq/checks-pyproject.toml | 2 +- .../license_header_format_.py | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/checks-superstaq/checks_superstaq/checks-pyproject.toml b/checks-superstaq/checks_superstaq/checks-pyproject.toml index 44ae58ba3..5efb5c6e5 100644 --- a/checks-superstaq/checks_superstaq/checks-pyproject.toml +++ b/checks-superstaq/checks_superstaq/checks-pyproject.toml @@ -1,5 +1,5 @@ [tool.license_header_format] -license_header = """# Copyright 2024 Infleqtion +license_header = """# Copyright {YEAR} {LICENSEE} # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 392176e67..9e2bdf6dc 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -160,7 +160,11 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: def _validate_license_header( - license_header_lst: list[LicenseHeader], licensee: str, license_name: str, editable: bool + license_header_lst: list[LicenseHeader], + expected_license_header: str, + licensee: str, + license_name: str, + editable: bool, ) -> bool: """Returns whether there is a valid license header in a file and for each license header in a file, it assigns each theiir type. @@ -177,12 +181,20 @@ def _validate_license_header( Returns: Whether there is a valid license header in a file or not. """ - valid_header_regex = re.compile(rf"(.*)Copyright(.*){licensee}") + target = ( + expected_license_header.replace("{YEAR}", ".*") + .replace("{LICENSEE}", licensee) + .replace("\n", "") + ) + print(target) + valid_header_regex = re.compile(rf"{target}") valid = False for license_header in license_header_lst: + print(re.match(valid_header_regex, license_header.license_header.replace("\n", ""))) + print(license_header.license_header.replace("\n", "")) if ( - re.search(valid_header_regex, license_header.license_header) + re.match(valid_header_regex, license_header.license_header) and license_name in license_header.license_header ): license_header.header_type = HeaderType.VALID @@ -393,7 +405,9 @@ def run_checker( if no_header and not bad_header: # if the --no-header flag is set return 0 - valid = _validate_license_header(license_header_lst, licensee, license_name, editable) + valid = _validate_license_header( + license_header_lst, expected_license_header, licensee, license_name, editable + ) append_flag = False # ensure the licensee is not appended to multiple headers exit_code = 0 From 89372a37acbd8283e05f26ec22de27cf699a4e61 Mon Sep 17 00:00:00 2001 From: nati Date: Tue, 6 Aug 2024 14:25:46 -0500 Subject: [PATCH 19/25] Use copyright body similarity license header in file to check if they are from the same license, wildcards in pyproject toml input --- .../checks_superstaq/checks-pyproject.toml | 5 +- .../license_header_format_.py | 99 +++++++++++-------- .../qiskit_superstaq/superstaq_backend.py | 16 ++- .../qiskit_superstaq/superstaq_job.py | 16 ++- .../qiskit_superstaq/superstaq_provider.py | 16 ++- 5 files changed, 104 insertions(+), 48 deletions(-) diff --git a/checks-superstaq/checks_superstaq/checks-pyproject.toml b/checks-superstaq/checks_superstaq/checks-pyproject.toml index 5efb5c6e5..3d2e26f1c 100644 --- a/checks-superstaq/checks_superstaq/checks-pyproject.toml +++ b/checks-superstaq/checks_superstaq/checks-pyproject.toml @@ -1,4 +1,5 @@ [tool.license_header_format] + license_header = """# Copyright {YEAR} {LICENSEE} # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,8 +12,8 @@ license_header = """# Copyright {YEAR} {LICENSEE} # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -# limitations under the License. -""" +# limitations under the License.""" + license_name = "Apache" licensee = "Infleqtion" editable = true diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index 9e2bdf6dc..ea1efd170 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - # Copyright 2024 Infleqtion # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +12,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - from __future__ import annotations import dataclasses +import datetime +import difflib import enum import re import sys @@ -30,9 +30,9 @@ from checks_superstaq import check_utils -def read_toml() -> tuple[str, str, str, bool] | None: +def read_toml() -> tuple[str, str, bool] | None: """Reads the pyproject.toml file to get license information. Fields should be under - [tool.license_header_format] and named `license_header`, `license_name`, `licensee` and + [tool.license_header_format] and named `license_header`, `licensee` and `editable`. Returns: @@ -50,15 +50,6 @@ def read_toml() -> tuple[str, str, str, bool] | None: ) return None - try: - license_name = str(data["tool"]["license_header_format"]["license_name"]) - except KeyError: - print( - "Under [tool.license_header_format] add a `license_name` field filled with the" - " license's name." - ) - return None - try: licensee = str(data["tool"]["license_header_format"]["licensee"]) except KeyError: @@ -77,7 +68,7 @@ def read_toml() -> tuple[str, str, str, bool] | None: ) return None - return expected_license_header, license_name, licensee, editable + return expected_license_header, licensee, editable class HeaderType(enum.Enum): @@ -147,7 +138,7 @@ def _extract_license_header(file: str) -> list[LicenseHeader]: if line == "\n": # set the line number for the last line of the license_header - license_header_lst[-1].license_header = license_header + license_header_lst[-1].license_header = license_header.strip() license_header_lst[-1].end_line_num = line_num + 1 license_header = "" else: @@ -163,7 +154,6 @@ def _validate_license_header( license_header_lst: list[LicenseHeader], expected_license_header: str, licensee: str, - license_name: str, editable: bool, ) -> bool: """Returns whether there is a valid license header in a file and for each license @@ -175,39 +165,59 @@ def _validate_license_header( Args: license_header_lst: List of the license_header objects for each header in a file. licensee: The owner of the expected license. - license_name: The name of the expected license. editable: Whether similar licenses can be edited to include the license owner instead adding the entire license to the file. Returns: Whether there is a valid license header in a file or not. """ + copyright_line = "" + body = "" + copyright_pattern = re.compile(r"Copyright .*") + header_as_lst = expected_license_header.split("\n") + + for idx, line in enumerate(header_as_lst): + if re.search(copyright_pattern, line): + copyright_line += line + body = "\n".join(header_as_lst[idx + 1 :]).strip("#") + break + else: + copyright_line += line + copyright_line = copyright_line.replace("{YEAR}", r"20\d{2}").replace("{LICENSEE}", licensee) + target = ( - expected_license_header.replace("{YEAR}", ".*") + expected_license_header.replace("{YEAR}", r"20\d{2}") .replace("{LICENSEE}", licensee) .replace("\n", "") + .replace("(", r"\(") + .replace(")", r"\)") + .replace(".", r"\.") + .replace("'", r"\'") + .replace('"', r"\"") + .strip() ) - print(target) - valid_header_regex = re.compile(rf"{target}") - valid = False + pattern = re.compile(target) + valid = False for license_header in license_header_lst: - print(re.match(valid_header_regex, license_header.license_header.replace("\n", ""))) - print(license_header.license_header.replace("\n", "")) - if ( - re.match(valid_header_regex, license_header.license_header) - and license_name in license_header.license_header + if re.match(pattern, license_header.license_header.replace("\n", "")): + license_header.header_type = HeaderType.VALID + valid = True + elif ( + difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 + and licensee in license_header.license_header ): license_header.header_type = HeaderType.VALID valid = True elif ( - re.search(valid_header_regex, license_header.license_header) - and license_name not in license_header.license_header + editable + and difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 + and licensee not in license_header.license_header ): + license_header.header_type = HeaderType.SIMILAR_LICENSE + elif re.search(re.compile(copyright_line), license_header.license_header): license_header.header_type = HeaderType.OUTDATED - elif not editable or license_name not in license_header.license_header: - license_header.header_type = HeaderType.OTHER else: - license_header.header_type = HeaderType.SIMILAR_LICENSE + license_header.header_type = HeaderType.OTHER return valid @@ -232,11 +242,11 @@ def _append_to_header(file: str, license_header: LicenseHeader, licensee: str) - and license_header.start_line_num <= line_num + 1 < license_header.end_line_num ): if line[-2] == ",": - prepend += line[:-1] + f" 2024 {licensee}.\n" + prepend += line[:-1] + f" {datetime.datetime.now().year} {licensee}.\n" elif line[-2].isalpha(): - prepend += line[:-1] + f", 2024 {licensee}.\n" + prepend += line[:-1] + f", {datetime.datetime.now().year} {licensee}.\n" else: - prepend += line[:-2] + f", 2024 {licensee}.\n" + prepend += line[:-2] + f", {datetime.datetime.now().year} {licensee}.\n" break prepend += line @@ -275,18 +285,24 @@ def _remove_header(file: str, license_header: LicenseHeader) -> None: f.truncate() -def _add_license_header(file: str, expected_license_header: str) -> None: +def _add_license_header(file: str, expected_license_header: str, licensee: str) -> None: """Adds the correct license header to a file. Args: file: The file name/path to which license header is added. expected_license_header: The target license header. + licensee: The owner of the expected license. Returns nothing. """ exceptions = ["# pylint:", "#!/", "# mypy:"] exception_lines = "" char_count = 0 + license_header = ( + expected_license_header.replace("{YEAR}", str(datetime.datetime.now().year)) + .replace("{LICENSEE}", licensee) + .strip() + ) with open(file, "r+") as f: for line in f: if any(line.startswith(exception) for exception in exceptions): @@ -298,7 +314,7 @@ def _add_license_header(file: str, expected_license_header: str) -> None: f.seek(char_count) content = f.read() f.seek(0) - f.write(exception_lines + expected_license_header + content) + f.write(exception_lines + license_header + "\n\n" + content.lstrip("\n")) f.truncate() @@ -364,7 +380,6 @@ def run_checker( no_header: bool, bad_header: bool, expected_license_header: str, - license_name: str, licensee: str, editable: bool, ) -> int: @@ -379,7 +394,6 @@ def run_checker( no_header: Whether to only handle files with no license headers. bad_header: Whether to only handle files with incorrect headers. expected_license_header: The target license header. - license_name: The name of the expected license. licensee: The owner of the expected license. editable: Whether similar licenses can be edited to include the license owner instead adding the entire license to the file. @@ -394,7 +408,7 @@ def run_checker( if len(license_header_lst) == 0: if (not no_header and not bad_header) or no_header: if apply: - _add_license_header(file, expected_license_header) + _add_license_header(file, expected_license_header, licensee) print(f"{styled_file_name}: {check_utils.success('License header added.')}") else: print(f"{styled_file_name}: {check_utils.warning('No license header found.')}") @@ -406,7 +420,7 @@ def run_checker( return 0 valid = _validate_license_header( - license_header_lst, expected_license_header, licensee, license_name, editable + license_header_lst, expected_license_header, licensee, editable ) append_flag = False # ensure the licensee is not appended to multiple headers exit_code = 0 @@ -430,7 +444,7 @@ def run_checker( ) if not valid and not append_flag and apply: - _add_license_header(file, expected_license_header) + _add_license_header(file, expected_license_header, licensee) print(f"{styled_file_name}: {check_utils.success('License header added.')}") return exit_code @@ -494,7 +508,7 @@ def run( return 0 if (toml_data := read_toml()) is not None: - expected_license_header, licensee, license_name, editable = toml_data + expected_license_header, licensee, editable = toml_data else: return 0 @@ -508,7 +522,6 @@ def run( parsed_args.bad_header, expected_license_header, licensee, - license_name, editable, ) diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py b/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py index cbd2ef9c6..f6a78bb93 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_backend.py @@ -1,6 +1,20 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # This code is part of Qiskit. # -# (C) Copyright IBM 2021, 2024 Infleqtion. +# (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_job.py b/qiskit-superstaq/qiskit_superstaq/superstaq_job.py index 833c62998..15d4bf87e 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_job.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_job.py @@ -1,6 +1,20 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # This code is part of Qiskit. # -# (C) Copyright IBM 2021, 2024 Infleqtion. +# (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py b/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py index b68f6a6a2..128bd45fe 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_provider.py @@ -1,6 +1,20 @@ +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # This code is part of Qiskit. # -# (C) Copyright IBM 2021, 2024 Infleqtion. +# (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory From ae9285ebc5f6a1648e6f41b470c7a564f85a01fe Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 8 Aug 2024 16:20:47 -0500 Subject: [PATCH 20/25] Replace checking for licensee in string with regex --- .../checks_superstaq/license_header_format_.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index ea1efd170..b551a3d2c 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -183,6 +183,7 @@ def _validate_license_header( else: copyright_line += line copyright_line = copyright_line.replace("{YEAR}", r"20\d{2}").replace("{LICENSEE}", licensee) + appended_pattern = re.compile(rf"Copyright .* 20\d{{2}} {licensee}") target = ( expected_license_header.replace("{YEAR}", r"20\d{2}") @@ -198,14 +199,14 @@ def _validate_license_header( pattern = re.compile(target) valid = False + for license_header in license_header_lst: if re.match(pattern, license_header.license_header.replace("\n", "")): license_header.header_type = HeaderType.VALID valid = True - elif ( - difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 - and licensee in license_header.license_header - ): + elif difflib.SequenceMatcher( + None, body, license_header.license_header + ).ratio() > 0.94 and re.search(appended_pattern, license_header.license_header): license_header.header_type = HeaderType.VALID valid = True elif ( From 8d79196009fe8ac9cea3be655324d34a3e889b4e Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 8 Aug 2024 16:35:56 -0500 Subject: [PATCH 21/25] fix indent --- checks-superstaq/checks_superstaq/all_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks-superstaq/checks_superstaq/all_.py b/checks-superstaq/checks_superstaq/all_.py index 45c310391..e56c8e480 100644 --- a/checks-superstaq/checks_superstaq/all_.py +++ b/checks-superstaq/checks_superstaq/all_.py @@ -100,7 +100,7 @@ def run(*args: str, sphinx_paths: list[str] | None = None) -> int: checks_failed |= flake8_.run(*args_to_pass, exit_on_failure=exit_on_failure, silent=True) checks_failed |= pylint_.run(*args_to_pass, exit_on_failure=exit_on_failure, silent=True) - checks_failed |= license_header_format_.run( + checks_failed |= license_header_format_.run( *args_to_pass, exit_on_failure=exit_on_failure, silent=True, From e5ac00e54970f84cc602508fb4fcaa80e67d5dbb Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 8 Aug 2024 16:38:26 -0500 Subject: [PATCH 22/25] add new line --- general-superstaq/general_superstaq/_version.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/general-superstaq/general_superstaq/_version.py b/general-superstaq/general_superstaq/_version.py index a34ff10ea..f53c89ec5 100644 --- a/general-superstaq/general_superstaq/_version.py +++ b/general-superstaq/general_superstaq/_version.py @@ -12,4 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.5.23" \ No newline at end of file +__version__ = "0.5.23" + From 9534d2c0dda85fd96783177cae604d4dbbaaf5d4 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 8 Aug 2024 16:52:28 -0500 Subject: [PATCH 23/25] add license headers and minor fix for check --- .../checks_superstaq/license_header_format_.py | 2 +- checks-superstaq/checks_superstaq/ruff_format_.py | 14 ++++++++++++++ checks-superstaq/checks_superstaq/ruff_lint_.py | 14 ++++++++++++++ checks/ruff_format_.py | 14 ++++++++++++++ checks/ruff_lint_.py | 14 ++++++++++++++ general-superstaq/general_superstaq/_version.py | 1 - 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index b551a3d2c..f3174890f 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -212,7 +212,7 @@ def _validate_license_header( elif ( editable and difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 - and licensee not in license_header.license_header + and not re.search(appended_pattern, license_header.license_header) ): license_header.header_type = HeaderType.SIMILAR_LICENSE elif re.search(re.compile(copyright_line), license_header.license_header): diff --git a/checks-superstaq/checks_superstaq/ruff_format_.py b/checks-superstaq/checks_superstaq/ruff_format_.py index 1e9ac0110..05d53a0fe 100644 --- a/checks-superstaq/checks_superstaq/ruff_format_.py +++ b/checks-superstaq/checks_superstaq/ruff_format_.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from __future__ import annotations import subprocess diff --git a/checks-superstaq/checks_superstaq/ruff_lint_.py b/checks-superstaq/checks_superstaq/ruff_lint_.py index bab875161..29dca7e97 100644 --- a/checks-superstaq/checks_superstaq/ruff_lint_.py +++ b/checks-superstaq/checks_superstaq/ruff_lint_.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from __future__ import annotations import subprocess diff --git a/checks/ruff_format_.py b/checks/ruff_format_.py index d19c5cfc4..381cc977a 100755 --- a/checks/ruff_format_.py +++ b/checks/ruff_format_.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from __future__ import annotations import sys diff --git a/checks/ruff_lint_.py b/checks/ruff_lint_.py index 3f528faf6..4c15ad2fc 100755 --- a/checks/ruff_lint_.py +++ b/checks/ruff_lint_.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +# Copyright 2024 Infleqtion +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from __future__ import annotations import sys diff --git a/general-superstaq/general_superstaq/_version.py b/general-superstaq/general_superstaq/_version.py index f53c89ec5..c9b2a60e0 100644 --- a/general-superstaq/general_superstaq/_version.py +++ b/general-superstaq/general_superstaq/_version.py @@ -13,4 +13,3 @@ # limitations under the License. __version__ = "0.5.23" - From 0be382cc09a5a149ada1813ec1b64db8fff3e09f Mon Sep 17 00:00:00 2001 From: nati Date: Fri, 9 Aug 2024 11:35:23 -0500 Subject: [PATCH 24/25] add similarity check for exact match case, fix header --- .../checks_superstaq/license_header_format_.py | 10 +++++----- docs/source/conf.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index f3174890f..a415a5bf4 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -201,21 +201,21 @@ def _validate_license_header( valid = False for license_header in license_header_lst: - if re.match(pattern, license_header.license_header.replace("\n", "")): + similarity = difflib.SequenceMatcher(None, body, license_header.license_header).ratio() + if re.match(pattern, license_header.license_header.replace("\n", "")) and similarity > 0.94: license_header.header_type = HeaderType.VALID valid = True - elif difflib.SequenceMatcher( - None, body, license_header.license_header - ).ratio() > 0.94 and re.search(appended_pattern, license_header.license_header): + elif similarity > 0.94 and re.search(appended_pattern, license_header.license_header): license_header.header_type = HeaderType.VALID valid = True elif ( editable - and difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 + and similarity > 0.94 and not re.search(appended_pattern, license_header.license_header) ): license_header.header_type = HeaderType.SIMILAR_LICENSE elif re.search(re.compile(copyright_line), license_header.license_header): + print("h") license_header.header_type = HeaderType.OUTDATED else: license_header.header_type = HeaderType.OTHER diff --git a/docs/source/conf.py b/docs/source/conf.py index 41be15fc1..cf1fcfc2a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: From 0330f2972a3485df45d6f6ef608e0aa8fde65147 Mon Sep 17 00:00:00 2001 From: nati Date: Fri, 9 Aug 2024 11:59:05 -0500 Subject: [PATCH 25/25] remove license_name field and improve similarity check accounting for headers with no body --- .../checks_superstaq/checks-pyproject.toml | 1 - .../checks_superstaq/license_header_format_.py | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/checks-superstaq/checks_superstaq/checks-pyproject.toml b/checks-superstaq/checks_superstaq/checks-pyproject.toml index 20f736049..6a7be844e 100644 --- a/checks-superstaq/checks_superstaq/checks-pyproject.toml +++ b/checks-superstaq/checks_superstaq/checks-pyproject.toml @@ -14,7 +14,6 @@ license_header = """# Copyright {YEAR} {LICENSEE} # See the License for the specific language governing permissions and # limitations under the License.""" -license_name = "Apache" licensee = "Infleqtion" editable = true diff --git a/checks-superstaq/checks_superstaq/license_header_format_.py b/checks-superstaq/checks_superstaq/license_header_format_.py index a415a5bf4..d3650a834 100644 --- a/checks-superstaq/checks_superstaq/license_header_format_.py +++ b/checks-superstaq/checks_superstaq/license_header_format_.py @@ -201,21 +201,23 @@ def _validate_license_header( valid = False for license_header in license_header_lst: - similarity = difflib.SequenceMatcher(None, body, license_header.license_header).ratio() - if re.match(pattern, license_header.license_header.replace("\n", "")) and similarity > 0.94: + similar_body = ( + difflib.SequenceMatcher(None, body, license_header.license_header).ratio() > 0.94 + or not body + ) + if re.match(pattern, license_header.license_header.replace("\n", "")) and similar_body: license_header.header_type = HeaderType.VALID valid = True - elif similarity > 0.94 and re.search(appended_pattern, license_header.license_header): + elif similar_body and re.search(appended_pattern, license_header.license_header): license_header.header_type = HeaderType.VALID valid = True elif ( editable - and similarity > 0.94 + and similar_body and not re.search(appended_pattern, license_header.license_header) ): license_header.header_type = HeaderType.SIMILAR_LICENSE elif re.search(re.compile(copyright_line), license_header.license_header): - print("h") license_header.header_type = HeaderType.OUTDATED else: license_header.header_type = HeaderType.OTHER