diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cbb4a473d..774b001ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,3 +40,10 @@ repos: pass_filenames: false types: [python] additional_dependencies: ["pyright@1.1.278"] + - repo: local + hooks: + - id: check-license-header + name: Check License Header + entry: ./utils/linting/check_file_header.py + language: python + types: [python] diff --git a/examples/todomvc/mvctests/test_clear_completed_button.py b/examples/todomvc/mvctests/test_clear_completed_button.py index 0d7757f06..a36b5b2b0 100644 --- a/examples/todomvc/mvctests/test_clear_completed_button.py +++ b/examples/todomvc/mvctests/test_clear_completed_button.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_counter.py b/examples/todomvc/mvctests/test_counter.py index 150ac085e..17bc98637 100644 --- a/examples/todomvc/mvctests/test_counter.py +++ b/examples/todomvc/mvctests/test_counter.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_editing.py b/examples/todomvc/mvctests/test_editing.py index 8fa0c6d7d..39d5caad6 100644 --- a/examples/todomvc/mvctests/test_editing.py +++ b/examples/todomvc/mvctests/test_editing.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_item.py b/examples/todomvc/mvctests/test_item.py index 52f5ea834..99cef20f5 100644 --- a/examples/todomvc/mvctests/test_item.py +++ b/examples/todomvc/mvctests/test_item.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_mark_all_as_completed.py b/examples/todomvc/mvctests/test_mark_all_as_completed.py index a3e55108b..bec157bd8 100644 --- a/examples/todomvc/mvctests/test_mark_all_as_completed.py +++ b/examples/todomvc/mvctests/test_mark_all_as_completed.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_new_todo.py b/examples/todomvc/mvctests/test_new_todo.py index 5619e9a6f..15a0dbbbf 100644 --- a/examples/todomvc/mvctests/test_new_todo.py +++ b/examples/todomvc/mvctests/test_new_todo.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 re from typing import Generator diff --git a/examples/todomvc/mvctests/test_persistence.py b/examples/todomvc/mvctests/test_persistence.py index b417cdbaa..37457d51b 100644 --- a/examples/todomvc/mvctests/test_persistence.py +++ b/examples/todomvc/mvctests/test_persistence.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/test_routing.py b/examples/todomvc/mvctests/test_routing.py index 0b004575f..2d7efa3d2 100644 --- a/examples/todomvc/mvctests/test_routing.py +++ b/examples/todomvc/mvctests/test_routing.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Generator import pytest diff --git a/examples/todomvc/mvctests/utils.py b/examples/todomvc/mvctests/utils.py index ba3d5decb..e0bf6ae1d 100644 --- a/examples/todomvc/mvctests/utils.py +++ b/examples/todomvc/mvctests/utils.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 playwright.sync_api import Page TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"] diff --git a/playwright/_impl/_har_router.py b/playwright/_impl/_har_router.py index 18e8b62e9..a96ba70bf 100644 --- a/playwright/_impl/_har_router.py +++ b/playwright/_impl/_har_router.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 asyncio import base64 from typing import TYPE_CHECKING, Optional, cast diff --git a/playwright/_impl/_map.py b/playwright/_impl/_map.py index d5c2dc5e4..95c05f445 100644 --- a/playwright/_impl/_map.py +++ b/playwright/_impl/_map.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Dict, Generic, Tuple, TypeVar K = TypeVar("K") diff --git a/playwright/_impl/_set_input_files_helpers.py b/playwright/_impl/_set_input_files_helpers.py index 2ee52347b..8aabc4c61 100644 --- a/playwright/_impl/_set_input_files_helpers.py +++ b/playwright/_impl/_set_input_files_helpers.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 base64 import os import sys diff --git a/scripts/update_versions.py b/scripts/update_versions.py index a9f6bb503..50d8fff78 100644 --- a/scripts/update_versions.py +++ b/scripts/update_versions.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 re from pathlib import Path diff --git a/tests/async/conftest.py b/tests/async/conftest.py index 1048be55c..ba141fcd5 100644 --- a/tests/async/conftest.py +++ b/tests/async/conftest.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_accessibility.py b/tests/async/test_accessibility.py index 8b2ff2e16..fa9a54b97 100644 --- a/tests/async/test_accessibility.py +++ b/tests/async/test_accessibility.py @@ -1,10 +1,10 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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 +# 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, diff --git a/tests/async/test_add_init_script.py b/tests/async/test_add_init_script.py index 515891a88..07279f5a1 100644 --- a/tests/async/test_add_init_script.py +++ b/tests/async/test_add_init_script.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_assertions.py b/tests/async/test_assertions.py index 2e8e262a6..91d16b0c5 100644 --- a/tests/async/test_assertions.py +++ b/tests/async/test_assertions.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_asyncio.py b/tests/async/test_asyncio.py index 4d6174d1b..7ee019ead 100644 --- a/tests/async/test_asyncio.py +++ b/tests/async/test_asyncio.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_browser.py b/tests/async/test_browser.py index b9124c102..17bfb5b2f 100644 --- a/tests/async/test_browser.py +++ b/tests/async/test_browser.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_browsercontext_service_worker_policy.py b/tests/async/test_browsercontext_service_worker_policy.py index 71a9636c7..7adcd2d54 100644 --- a/tests/async/test_browsercontext_service_worker_policy.py +++ b/tests/async/test_browsercontext_service_worker_policy.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 playwright.async_api import Browser from tests.server import Server diff --git a/tests/async/test_chromium_tracing.py b/tests/async/test_chromium_tracing.py index deb2b10ae..f1c34b5ba 100644 --- a/tests/async/test_chromium_tracing.py +++ b/tests/async/test_chromium_tracing.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_device_descriptors.py b/tests/async/test_device_descriptors.py index e8ca64625..ee2e72cdd 100644 --- a/tests/async/test_device_descriptors.py +++ b/tests/async/test_device_descriptors.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 diff --git a/tests/async/test_headful.py b/tests/async/test_headful.py index 8939bf0c2..bc1df9b69 100644 --- a/tests/async/test_headful.py +++ b/tests/async/test_headful.py @@ -1,10 +1,10 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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 +# 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, diff --git a/tests/async/test_queryselector.py b/tests/async/test_queryselector.py index 65e2700dd..814f7a3a9 100644 --- a/tests/async/test_queryselector.py +++ b/tests/async/test_queryselector.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 from playwright.async_api import Error, Page diff --git a/tests/async/test_selectors_text.py b/tests/async/test_selectors_text.py index 9de7f6b4d..0b231ccab 100644 --- a/tests/async/test_selectors_text.py +++ b/tests/async/test_selectors_text.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 re import pytest diff --git a/tests/async/test_tracing.py b/tests/async/test_tracing.py index 13f510591..1473ab648 100644 --- a/tests/async/test_tracing.py +++ b/tests/async/test_tracing.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/async/test_worker.py b/tests/async/test_worker.py index 399df4407..08d6bd0cc 100644 --- a/tests/async/test_worker.py +++ b/tests/async/test_worker.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/common/test_collect_handles.py b/tests/common/test_collect_handles.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/common/test_events.py b/tests/common/test_events.py index ac2ffe931..07d6c4e2b 100644 --- a/tests/common/test_events.py +++ b/tests/common/test_events.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 typing import Dict import pytest diff --git a/tests/common/test_signals.py b/tests/common/test_signals.py index 7d78865ce..472e74042 100644 --- a/tests/common/test_signals.py +++ b/tests/common/test_signals.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 asyncio import multiprocessing import os diff --git a/tests/common/test_threads.py b/tests/common/test_threads.py index 6d4b1963e..b957244f2 100644 --- a/tests/common/test_threads.py +++ b/tests/common/test_threads.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/conftest.py b/tests/conftest.py index 3c44f908c..a3b8e9992 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/conftest.py b/tests/sync/conftest.py index d7942bf90..075cccde2 100644 --- a/tests/sync/conftest.py +++ b/tests/sync/conftest.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_accessibility.py b/tests/sync/test_accessibility.py index d71f27a4d..d7516d6d9 100644 --- a/tests/sync/test_accessibility.py +++ b/tests/sync/test_accessibility.py @@ -1,10 +1,10 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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 +# 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, diff --git a/tests/sync/test_add_init_script.py b/tests/sync/test_add_init_script.py index 039862063..e17fc5e8b 100644 --- a/tests/sync/test_add_init_script.py +++ b/tests/sync/test_add_init_script.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_assertions.py b/tests/sync/test_assertions.py index 724f1d980..7d53d18a6 100644 --- a/tests/sync/test_assertions.py +++ b/tests/sync/test_assertions.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_browser.py b/tests/sync/test_browser.py index 31d43e68f..ded881c67 100644 --- a/tests/sync/test_browser.py +++ b/tests/sync/test_browser.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_browsercontext_service_worker_policy.py b/tests/sync/test_browsercontext_service_worker_policy.py index 7f4350d7f..190bdfbd5 100644 --- a/tests/sync/test_browsercontext_service_worker_policy.py +++ b/tests/sync/test_browsercontext_service_worker_policy.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 playwright.sync_api import Browser from tests.server import Server diff --git a/tests/sync/test_locator_get_by.py b/tests/sync/test_locator_get_by.py index 42939672f..0e5d4396b 100644 --- a/tests/sync/test_locator_get_by.py +++ b/tests/sync/test_locator_get_by.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_queryselector.py b/tests/sync/test_queryselector.py index 367b90e9a..f773b5109 100644 --- a/tests/sync/test_queryselector.py +++ b/tests/sync/test_queryselector.py @@ -1,3 +1,16 @@ +# Copyright (c) Microsoft Corporation. +# +# 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 pathlib import Path import pytest diff --git a/tests/sync/test_sync.py b/tests/sync/test_sync.py index 11f6aab08..e22490426 100644 --- a/tests/sync/test_sync.py +++ b/tests/sync/test_sync.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/sync/test_tracing.py b/tests/sync/test_tracing.py index 5c5084240..61e67009d 100644 --- a/tests/sync/test_tracing.py +++ b/tests/sync/test_tracing.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/test_generation_scripts.py b/tests/test_generation_scripts.py index 91127dc02..9a4f78293 100644 --- a/tests/test_generation_scripts.py +++ b/tests/test_generation_scripts.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/test_installation.py b/tests/test_installation.py index ccde56361..e0f9433ab 100644 --- a/tests/test_installation.py +++ b/tests/test_installation.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/tests/test_reference_count_async.py b/tests/test_reference_count_async.py index 345be83a5..cc1564aa6 100644 --- a/tests/test_reference_count_async.py +++ b/tests/test_reference_count_async.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # -# Licensed under the Apache License, Version 2.0 (the "License") +# 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/utils/linting/check_file_header.py b/utils/linting/check_file_header.py new file mode 100755 index 000000000..5ccf79d5f --- /dev/null +++ b/utils/linting/check_file_header.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# Copyright (c) Microsoft Corporation. +# +# 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 +from pathlib import Path +from typing import List + +LICENSE_HEADER = """ +# Copyright (c) Microsoft Corporation. +# +# 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. +""".strip() + + +def file_has_license(file_path: str) -> None: + path = Path(file_path) + if not path.name.endswith(".py"): + return + if not path.exists(): + raise Exception(f"File {file_path} does not exist") + content = path.read_text(encoding="utf-8") + if content.strip() == "": + return + if content.startswith("#!"): + # flake8: noqa: E203 + content = content[content.find("\n") + 1 :] + if not content.startswith(LICENSE_HEADER): + raise Exception(f"File {file_path} does not have license header") + + +def main() -> None: + errors: List[str] = [] + + for file_path in sys.argv[1:]: + try: + file_has_license(file_path) + except Exception as e: + errors.append(str(e)) + + if errors: + print("Missing license header in files:") + for error in errors: + print(" -", error) + sys.exit(1) + + +if __name__ == "__main__": + main()