1diff --git a/pw_presubmit/py/pw_presubmit/build.py b/pw_presubmit/py/pw_presubmit/build.py 2index 4a370e33..224ad9c6 100644 3--- a/pw_presubmit/py/pw_presubmit/build.py 4+++ b/pw_presubmit/py/pw_presubmit/build.py 5@@ -20,7 +20,6 @@ from pathlib import Path 6 import re 7 from typing import Container, Dict, Iterable, List, Mapping, Set, Tuple 8 9-from pw_package import package_manager 10 from pw_presubmit import call, log_run, plural, PresubmitFailure, tools 11 12 _LOG = logging.getLogger(__name__) 13diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_presubmit/format_code.py 14index 19d09546..c1ff6b5a 100755 15--- a/pw_presubmit/py/pw_presubmit/format_code.py 16+++ b/pw_presubmit/py/pw_presubmit/format_code.py 17@@ -142,7 +142,7 @@ def fix_go_format(files: Iterable[Path]) -> None: 18 19 20 def _yapf(*args, **kwargs) -> subprocess.CompletedProcess: 21- return log_run(['python', '-m', 'yapf', '--parallel', *args], 22+ return log_run(['python', '-m', 'yapf', '--style', '{based_on_style:pep8,indent_width:2}', '--parallel', *args], 23 capture_output=True, 24 **kwargs) 25 26@@ -229,11 +229,6 @@ def print_format_check(errors: Dict[Path, str], 27 except ValueError: 28 return Path(path).resolve() 29 30- message = (f' pw format --fix {path_relative_to_cwd(path)}' 31- for path in errors) 32- _LOG.warning('To fix formatting, run:\n\n%s\n', '\n'.join(message)) 33- 34- 35 class CodeFormat(NamedTuple): 36 language: str 37 extensions: Collection[str] 38diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py 39index 794967db..061db7ea 100755 40--- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py 41+++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py 42@@ -220,8 +220,8 @@ def clang_tidy(ctx: PresubmitContext): 43 44 45 # The first line must be regex because of the '20\d\d' date 46-COPYRIGHT_FIRST_LINE = r'Copyright 20\d\d The Pigweed Authors' 47-COPYRIGHT_COMMENTS = r'(#|//| \*|REM|::)' 48+COPYRIGHT_FIRST_LINE = r'Copyright 20\d\d The TensorFlow Authors. All Rights Reserved.' 49+COPYRIGHT_COMMENTS = r'(#|//|\*|REM|::|/\*)' 50 COPYRIGHT_BLOCK_COMMENTS = ( 51 # HTML comments 52 (r'<!--', r'-->'), ) 53@@ -232,21 +232,23 @@ COPYRIGHT_FIRST_LINE_EXCEPTIONS = ( 54 '@echo off', 55 '# -*-', 56 ':', 57+ '# Lint as', 58+ '# coding=utf-8' 59 ) 60 61 COPYRIGHT_LINES = tuple("""\ 62 63-Licensed under the Apache License, Version 2.0 (the "License"); you may not 64-use this file except in compliance with the License. You may obtain a copy of 65-the License at 66+Licensed under the Apache License, Version 2.0 (the "License"); 67+you may not use this file except in compliance with the License. 68+You may obtain a copy of the License at 69 70- https://www.apache.org/licenses/LICENSE-2.0 71+ http://www.apache.org/licenses/LICENSE-2.0 72 73 Unless required by applicable law or agreed to in writing, software 74-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 75-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 76-License for the specific language governing permissions and limitations under 77-the License. 78+distributed under the License is distributed on an "AS IS" BASIS, 79+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 80+See the License for the specific language governing permissions and 81+limitations under the License. 82 """.splitlines()) 83 84 _EXCLUDE_FROM_COPYRIGHT_NOTICE: Sequence[str] = ( 85@@ -344,6 +346,11 @@ def copyright_notice(ctx: PresubmitContext): 86 errors.append(path) 87 continue 88 89+ # Special handling for TFLM style of copyright+license in the cc 90+ # files. 91+ if comment == '/*': 92+ comment = '' 93+ 94 if end_block_comment: 95 expected_lines = COPYRIGHT_LINES + (end_block_comment, ) 96 else: 97@@ -354,6 +361,10 @@ def copyright_notice(ctx: PresubmitContext): 98 expected_line = expected + '\n' 99 elif comment: 100 expected_line = (comment + ' ' + expected).rstrip() + '\n' 101+ else: 102+ # Special handling for TFLM style of copyright+license in 103+ # the cc files. 104+ expected_line = (expected).rstrip() + '\n' 105 106 if expected_line != actual: 107 _LOG.warning(' bad line: %r', actual) 108@@ -475,6 +486,10 @@ BROKEN = ( 109 gn_nanopb_build, 110 ) 111 112+COPYRIGHT_NOTICE = ( 113+ copyright_notice, 114+) 115+ 116 QUICK = ( 117 commit_message_format, 118 init_cipd, 119@@ -509,7 +524,8 @@ FULL = ( 120 build_env_setup, 121 ) 122 123-PROGRAMS = Programs(broken=BROKEN, quick=QUICK, full=FULL) 124+PROGRAMS = Programs(broken=BROKEN, quick=QUICK, full=FULL, 125+ copyright_notice=COPYRIGHT_NOTICE) 126 127 128 def parse_args() -> argparse.Namespace: 129