mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Allow to keep old python style for existing files.
https://webrtc-review.googlesource.com/c/src/+/321081 made PEP-8 mandatory for WebRTC python file. This CL allows to keep the old formatting style for existing python files because switching all methods and functions name from PascalCase to snake_case is non trivial. Change-Id: Id094bbf72ee1c3c32027a49bc9763bc65dfb9ad2 Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323860 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Reviewed-by: Christoffer Jansson <jansson@google.com> Cr-Commit-Position: refs/heads/main@{#40951}
This commit is contained in:
parent
c2994790a1
commit
3d476f2738
3 changed files with 1291 additions and 1029 deletions
|
@ -10,6 +10,7 @@ per-file .vpython3=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
||||||
per-file AUTHORS=*
|
per-file AUTHORS=*
|
||||||
per-file DEPS=*
|
per-file DEPS=*
|
||||||
per-file pylintrc=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
per-file pylintrc=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
||||||
|
per-file pylintrc_old_style=mbonadei@webrtc.org,jansson@webrtc.org,jleconte@webrtc.org
|
||||||
per-file WATCHLISTS=*
|
per-file WATCHLISTS=*
|
||||||
per-file native-api.md=mbonadei@webrtc.org
|
per-file native-api.md=mbonadei@webrtc.org
|
||||||
per-file ....lua=titovartem@webrtc.org
|
per-file ....lua=titovartem@webrtc.org
|
||||||
|
|
211
PRESUBMIT.py
211
PRESUBMIT.py
|
@ -47,6 +47,10 @@ CPPLINT_EXCEPTIONS = [
|
||||||
'voice_engine',
|
'voice_engine',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
PYLINT_OLD_STYLE = [
|
||||||
|
"PRESUBMIT.py",
|
||||||
|
]
|
||||||
|
|
||||||
# These filters will always be removed, even if the caller specifies a filter
|
# These filters will always be removed, even if the caller specifies a filter
|
||||||
# set, as they are problematic or broken in some way.
|
# set, as they are problematic or broken in some way.
|
||||||
#
|
#
|
||||||
|
@ -144,8 +148,8 @@ def VerifyNativeApiHeadersListIsValid(input_api, output_api):
|
||||||
"""Ensures the list of native API header directories is up to date."""
|
"""Ensures the list of native API header directories is up to date."""
|
||||||
non_existing_paths = []
|
non_existing_paths = []
|
||||||
native_api_full_paths = [
|
native_api_full_paths = [
|
||||||
input_api.os_path.join(input_api.PresubmitLocalPath(), *path.split('/'))
|
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||||
for path in API_DIRS
|
*path.split('/')) for path in API_DIRS
|
||||||
]
|
]
|
||||||
for path in native_api_full_paths:
|
for path in native_api_full_paths:
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
|
@ -207,8 +211,8 @@ def CheckNoIOStreamInHeaders(input_api, output_api, source_file_filter):
|
||||||
files = []
|
files = []
|
||||||
pattern = input_api.re.compile(r'^#include\s*<iostream>',
|
pattern = input_api.re.compile(r'^#include\s*<iostream>',
|
||||||
input_api.re.MULTILINE)
|
input_api.re.MULTILINE)
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||||
x))
|
source_file_filter(x))
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
if not f.LocalPath().endswith('.h'):
|
if not f.LocalPath().endswith('.h'):
|
||||||
continue
|
continue
|
||||||
|
@ -221,7 +225,8 @@ def CheckNoIOStreamInHeaders(input_api, output_api, source_file_filter):
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
'Do not #include <iostream> in header files, since it inserts '
|
'Do not #include <iostream> in header files, since it inserts '
|
||||||
'static initialization into every file including the header. '
|
'static initialization into every file including the header. '
|
||||||
'Instead, #include <ostream>. See http://crbug.com/94794', files)
|
'Instead, #include <ostream>. See http://crbug.com/94794',
|
||||||
|
files)
|
||||||
]
|
]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -230,8 +235,8 @@ def CheckNoPragmaOnce(input_api, output_api, source_file_filter):
|
||||||
"""Make sure that banned functions are not used."""
|
"""Make sure that banned functions are not used."""
|
||||||
files = []
|
files = []
|
||||||
pattern = input_api.re.compile(r'^#pragma\s+once', input_api.re.MULTILINE)
|
pattern = input_api.re.compile(r'^#pragma\s+once', input_api.re.MULTILINE)
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||||
x))
|
source_file_filter(x))
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
if not f.LocalPath().endswith('.h'):
|
if not f.LocalPath().endswith('.h'):
|
||||||
continue
|
continue
|
||||||
|
@ -258,8 +263,8 @@ def CheckNoFRIEND_TEST(# pylint: disable=invalid-name
|
||||||
used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes."""
|
used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes."""
|
||||||
problems = []
|
problems = []
|
||||||
|
|
||||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
source_file_filter(f))
|
('.cc', '.h')) and source_file_filter(f))
|
||||||
for f in input_api.AffectedFiles(file_filter=file_filter):
|
for f in input_api.AffectedFiles(file_filter=file_filter):
|
||||||
for line_num, line in f.ChangedContents():
|
for line_num, line in f.ChangedContents():
|
||||||
if 'FRIEND_TEST(' in line:
|
if 'FRIEND_TEST(' in line:
|
||||||
|
@ -314,7 +319,8 @@ def CheckApprovedFilesLintClean(input_api, output_api,
|
||||||
files = []
|
files = []
|
||||||
for f in input_api.AffectedSourceFiles(source_file_filter):
|
for f in input_api.AffectedSourceFiles(source_file_filter):
|
||||||
# Note that moved/renamed files also count as added.
|
# Note that moved/renamed files also count as added.
|
||||||
if f.Action() == 'A' or not IsLintDisabled(disabled_paths, f.LocalPath()):
|
if f.Action() == 'A' or not IsLintDisabled(disabled_paths,
|
||||||
|
f.LocalPath()):
|
||||||
files.append(f.AbsoluteLocalPath())
|
files.append(f.AbsoluteLocalPath())
|
||||||
|
|
||||||
for file_name in files:
|
for file_name in files:
|
||||||
|
@ -342,7 +348,8 @@ def CheckNoSourcesAbove(input_api, gn_files, output_api):
|
||||||
for source_block_match in source_pattern.finditer(contents):
|
for source_block_match in source_pattern.finditer(contents):
|
||||||
# Find all source list entries starting with ../ in the source block
|
# Find all source list entries starting with ../ in the source block
|
||||||
# (exclude overrides entries).
|
# (exclude overrides entries).
|
||||||
for file_list_match in file_pattern.finditer(source_block_match.group(1)):
|
for file_list_match in file_pattern.finditer(
|
||||||
|
source_block_match.group(1)):
|
||||||
source_file = file_list_match.group(1)
|
source_file = file_list_match.group(1)
|
||||||
if 'overrides/' not in source_file:
|
if 'overrides/' not in source_file:
|
||||||
violating_source_entries.append(source_file)
|
violating_source_entries.append(source_file)
|
||||||
|
@ -387,7 +394,8 @@ def CheckAbseilDependencies(input_api, gn_files, output_api):
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
if re.search(absl_re, dep):
|
if re.search(absl_re, dep):
|
||||||
errors.append(
|
errors.append(
|
||||||
output_api.PresubmitError(error_msg %
|
output_api.PresubmitError(
|
||||||
|
error_msg %
|
||||||
(target_name, gn_file.LocalPath())))
|
(target_name, gn_file.LocalPath())))
|
||||||
break # no need to warn more than once per target
|
break # no need to warn more than once per target
|
||||||
return errors
|
return errors
|
||||||
|
@ -398,7 +406,6 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
||||||
|
|
||||||
See bugs.webrtc.org/7743 for more context.
|
See bugs.webrtc.org/7743 for more context.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _MoreThanOneSourceUsed(*sources_lists):
|
def _MoreThanOneSourceUsed(*sources_lists):
|
||||||
sources_used = 0
|
sources_used = 0
|
||||||
for source_list in sources_lists:
|
for source_list in sources_lists:
|
||||||
|
@ -436,7 +443,8 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
||||||
c_files = []
|
c_files = []
|
||||||
cc_files = []
|
cc_files = []
|
||||||
objc_files = []
|
objc_files = []
|
||||||
for file_match in FILE_PATH_RE.finditer(sources_match.group(1)):
|
for file_match in FILE_PATH_RE.finditer(
|
||||||
|
sources_match.group(1)):
|
||||||
file_path = file_match.group('file_path')
|
file_path = file_match.group('file_path')
|
||||||
extension = file_match.group('extension')
|
extension = file_match.group('extension')
|
||||||
if extension == '.c':
|
if extension == '.c':
|
||||||
|
@ -447,9 +455,12 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
||||||
objc_files.append(file_path + extension)
|
objc_files.append(file_path + extension)
|
||||||
list_of_sources.append((c_files, cc_files, objc_files))
|
list_of_sources.append((c_files, cc_files, objc_files))
|
||||||
for c_files_list, cc_files_list, objc_files_list in list_of_sources:
|
for c_files_list, cc_files_list, objc_files_list in list_of_sources:
|
||||||
if _MoreThanOneSourceUsed(c_files_list, cc_files_list, objc_files_list):
|
if _MoreThanOneSourceUsed(c_files_list, cc_files_list,
|
||||||
all_sources = sorted(c_files_list + cc_files_list + objc_files_list)
|
objc_files_list):
|
||||||
errors[gn_file.LocalPath()].append((target_name, all_sources))
|
all_sources = sorted(c_files_list + cc_files_list +
|
||||||
|
objc_files_list)
|
||||||
|
errors[gn_file.LocalPath()].append(
|
||||||
|
(target_name, all_sources))
|
||||||
if errors:
|
if errors:
|
||||||
return [
|
return [
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
|
@ -467,9 +478,12 @@ def CheckNoMixingSources(input_api, gn_files, output_api):
|
||||||
def CheckNoPackageBoundaryViolations(input_api, gn_files, output_api):
|
def CheckNoPackageBoundaryViolations(input_api, gn_files, output_api):
|
||||||
cwd = input_api.PresubmitLocalPath()
|
cwd = input_api.PresubmitLocalPath()
|
||||||
with _AddToPath(
|
with _AddToPath(
|
||||||
input_api.os_path.join(cwd, 'tools_webrtc', 'presubmit_checks_lib')):
|
input_api.os_path.join(cwd, 'tools_webrtc',
|
||||||
|
'presubmit_checks_lib')):
|
||||||
from check_package_boundaries import CheckPackageBoundaries
|
from check_package_boundaries import CheckPackageBoundaries
|
||||||
build_files = [os.path.join(cwd, gn_file.LocalPath()) for gn_file in gn_files]
|
build_files = [
|
||||||
|
os.path.join(cwd, gn_file.LocalPath()) for gn_file in gn_files
|
||||||
|
]
|
||||||
errors = CheckPackageBoundaries(cwd, build_files)[:5]
|
errors = CheckPackageBoundaries(cwd, build_files)[:5]
|
||||||
if errors:
|
if errors:
|
||||||
return [
|
return [
|
||||||
|
@ -500,7 +514,8 @@ def CheckNoWarningSuppressionFlagsAreAdded(gn_files,
|
||||||
'\n'
|
'\n'
|
||||||
'Affected files:\n')
|
'Affected files:\n')
|
||||||
errors = [] # 2-element tuples with (file, line number)
|
errors = [] # 2-element tuples with (file, line number)
|
||||||
clang_warn_re = input_api.re.compile(r'//build/config/clang:extra_warnings')
|
clang_warn_re = input_api.re.compile(
|
||||||
|
r'//build/config/clang:extra_warnings')
|
||||||
# pylint: disable-next=fixme
|
# pylint: disable-next=fixme
|
||||||
no_presubmit_re = input_api.re.compile(
|
no_presubmit_re = input_api.re.compile(
|
||||||
r'# no-presubmit-check TODO\(bugs\.webrtc\.org/\d+\)')
|
r'# no-presubmit-check TODO\(bugs\.webrtc\.org/\d+\)')
|
||||||
|
@ -539,7 +554,8 @@ def CheckNoStreamUsageIsAdded(input_api,
|
||||||
source_file_filter,
|
source_file_filter,
|
||||||
error_formatter=_ReportFileAndLine):
|
error_formatter=_ReportFileAndLine):
|
||||||
"""Make sure that no more dependencies on stringstream are added."""
|
"""Make sure that no more dependencies on stringstream are added."""
|
||||||
error_msg = ('Usage of <sstream>, <istream> and <ostream> in WebRTC is '
|
error_msg = (
|
||||||
|
'Usage of <sstream>, <istream> and <ostream> in WebRTC is '
|
||||||
'deprecated.\n'
|
'deprecated.\n'
|
||||||
'This includes the following types:\n'
|
'This includes the following types:\n'
|
||||||
'std::istringstream, std::ostringstream, std::wistringstream, '
|
'std::istringstream, std::ostringstream, std::wistringstream, '
|
||||||
|
@ -559,18 +575,19 @@ def CheckNoStreamUsageIsAdded(input_api,
|
||||||
'Affected files:\n')
|
'Affected files:\n')
|
||||||
errors = [] # 2-element tuples with (file, line number)
|
errors = [] # 2-element tuples with (file, line number)
|
||||||
include_re = input_api.re.compile(r'#include <(i|o|s)stream>')
|
include_re = input_api.re.compile(r'#include <(i|o|s)stream>')
|
||||||
usage_re = input_api.re.compile(r'std::(w|i|o|io|wi|wo|wio)(string)*stream')
|
usage_re = input_api.re.compile(
|
||||||
|
r'std::(w|i|o|io|wi|wo|wio)(string)*stream')
|
||||||
no_presubmit_re = input_api.re.compile(
|
no_presubmit_re = input_api.re.compile(
|
||||||
r'// no-presubmit-check TODO\(webrtc:8982\)')
|
r'// no-presubmit-check TODO\(webrtc:8982\)')
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||||
x))
|
source_file_filter(x))
|
||||||
|
|
||||||
def _IsException(file_path):
|
def _IsException(file_path):
|
||||||
is_test = any(
|
is_test = any(
|
||||||
file_path.endswith(x)
|
file_path.endswith(x) for x in
|
||||||
for x in ['_test.cc', '_tests.cc', '_unittest.cc', '_unittests.cc'])
|
['_test.cc', '_tests.cc', '_unittest.cc', '_unittests.cc'])
|
||||||
return (file_path.startswith('examples') or file_path.startswith('test')
|
return (file_path.startswith('examples')
|
||||||
or is_test)
|
or file_path.startswith('test') or is_test)
|
||||||
|
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
# Usage of stringstream is allowed under examples/ and in tests.
|
# Usage of stringstream is allowed under examples/ and in tests.
|
||||||
|
@ -604,13 +621,15 @@ def CheckPublicDepsIsNotUsed(gn_files, input_api, output_api):
|
||||||
if not surpressed:
|
if not surpressed:
|
||||||
result.append(
|
result.append(
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
error_msg % (affected_file.LocalPath(), line_number)))
|
error_msg %
|
||||||
|
(affected_file.LocalPath(), line_number)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
||||||
result = []
|
result = []
|
||||||
error_msg = ('check_includes overrides are not allowed since it can cause '
|
error_msg = (
|
||||||
|
'check_includes overrides are not allowed since it can cause '
|
||||||
'incorrect dependencies to form. It effectively means that your '
|
'incorrect dependencies to form. It effectively means that your '
|
||||||
'module can include any .h file without depending on its '
|
'module can include any .h file without depending on its '
|
||||||
'corresponding target. There are some exceptional cases when '
|
'corresponding target. There are some exceptional cases when '
|
||||||
|
@ -625,8 +644,8 @@ def CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api):
|
||||||
if ('check_includes' in affected_line
|
if ('check_includes' in affected_line
|
||||||
and not no_presubmit_re.search(affected_line)):
|
and not no_presubmit_re.search(affected_line)):
|
||||||
result.append(
|
result.append(
|
||||||
output_api.PresubmitError(error_msg %
|
output_api.PresubmitError(
|
||||||
(affected_file.LocalPath(), line_number)))
|
error_msg % (affected_file.LocalPath(), line_number)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -647,10 +666,13 @@ def CheckGnChanges(input_api, output_api):
|
||||||
result.extend(CheckAbseilDependencies(input_api, gn_files, output_api))
|
result.extend(CheckAbseilDependencies(input_api, gn_files, output_api))
|
||||||
result.extend(
|
result.extend(
|
||||||
CheckNoPackageBoundaryViolations(input_api, gn_files, output_api))
|
CheckNoPackageBoundaryViolations(input_api, gn_files, output_api))
|
||||||
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api, output_api))
|
result.extend(CheckPublicDepsIsNotUsed(gn_files, input_api,
|
||||||
result.extend(CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api))
|
output_api))
|
||||||
result.extend(
|
result.extend(
|
||||||
CheckNoWarningSuppressionFlagsAreAdded(gn_files, input_api, output_api))
|
CheckCheckIncludesIsNotUsed(gn_files, input_api, output_api))
|
||||||
|
result.extend(
|
||||||
|
CheckNoWarningSuppressionFlagsAreAdded(gn_files, input_api,
|
||||||
|
output_api))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -660,8 +682,8 @@ def CheckGnGen(input_api, output_api):
|
||||||
errors.
|
errors.
|
||||||
"""
|
"""
|
||||||
with _AddToPath(
|
with _AddToPath(
|
||||||
input_api.os_path.join(input_api.PresubmitLocalPath(), 'tools_webrtc',
|
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||||
'presubmit_checks_lib')):
|
'tools_webrtc', 'presubmit_checks_lib')):
|
||||||
from build_helpers import RunGnCheck
|
from build_helpers import RunGnCheck
|
||||||
errors = RunGnCheck(FindSrcDirPath(input_api.PresubmitLocalPath()))[:5]
|
errors = RunGnCheck(FindSrcDirPath(input_api.PresubmitLocalPath()))[:5]
|
||||||
if errors:
|
if errors:
|
||||||
|
@ -686,7 +708,8 @@ def CheckUnwantedDependencies(input_api, output_api, source_file_filter):
|
||||||
# roundabout construct to import checkdeps because this file is
|
# roundabout construct to import checkdeps because this file is
|
||||||
# eval-ed and thus doesn't have __file__.
|
# eval-ed and thus doesn't have __file__.
|
||||||
src_path = FindSrcDirPath(input_api.PresubmitLocalPath())
|
src_path = FindSrcDirPath(input_api.PresubmitLocalPath())
|
||||||
checkdeps_path = input_api.os_path.join(src_path, 'buildtools', 'checkdeps')
|
checkdeps_path = input_api.os_path.join(src_path, 'buildtools',
|
||||||
|
'checkdeps')
|
||||||
if not os.path.exists(checkdeps_path):
|
if not os.path.exists(checkdeps_path):
|
||||||
return [
|
return [
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
|
@ -743,7 +766,8 @@ def CheckCommitMessageBugEntry(input_api, output_api):
|
||||||
"""Check that bug entries are well-formed in commit message."""
|
"""Check that bug entries are well-formed in commit message."""
|
||||||
bogus_bug_msg = (
|
bogus_bug_msg = (
|
||||||
'Bogus Bug entry: %s. Please specify the issue tracker prefix and the '
|
'Bogus Bug entry: %s. Please specify the issue tracker prefix and the '
|
||||||
'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.')
|
'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.'
|
||||||
|
)
|
||||||
results = []
|
results = []
|
||||||
for bug in input_api.change.BugsFromDescription():
|
for bug in input_api.change.BugsFromDescription():
|
||||||
bug = bug.strip()
|
bug = bug.strip()
|
||||||
|
@ -756,7 +780,8 @@ def CheckCommitMessageBugEntry(input_api, output_api):
|
||||||
prefix_guess = 'chromium'
|
prefix_guess = 'chromium'
|
||||||
else:
|
else:
|
||||||
prefix_guess = 'webrtc'
|
prefix_guess = 'webrtc'
|
||||||
results.append('Bug entry requires issue tracker prefix, e.g. %s:%s' %
|
results.append(
|
||||||
|
'Bug entry requires issue tracker prefix, e.g. %s:%s' %
|
||||||
(prefix_guess, bug))
|
(prefix_guess, bug))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
results.append(bogus_bug_msg % bug)
|
results.append(bogus_bug_msg % bug)
|
||||||
|
@ -789,10 +814,9 @@ def CheckChangeHasBugField(input_api, output_api):
|
||||||
|
|
||||||
def CheckJSONParseErrors(input_api, output_api, source_file_filter):
|
def CheckJSONParseErrors(input_api, output_api, source_file_filter):
|
||||||
"""Check that JSON files do not contain syntax errors."""
|
"""Check that JSON files do not contain syntax errors."""
|
||||||
|
|
||||||
def FilterFile(affected_file):
|
def FilterFile(affected_file):
|
||||||
return (input_api.os_path.splitext(affected_file.LocalPath())[1] == '.json'
|
return (input_api.os_path.splitext(affected_file.LocalPath())[1]
|
||||||
and source_file_filter(affected_file))
|
== '.json' and source_file_filter(affected_file))
|
||||||
|
|
||||||
def GetJSONParseError(input_api, filename):
|
def GetJSONParseError(input_api, filename):
|
||||||
try:
|
try:
|
||||||
|
@ -809,7 +833,8 @@ def CheckJSONParseErrors(input_api, output_api, source_file_filter):
|
||||||
affected_file.AbsoluteLocalPath())
|
affected_file.AbsoluteLocalPath())
|
||||||
if parse_error:
|
if parse_error:
|
||||||
results.append(
|
results.append(
|
||||||
output_api.PresubmitError('%s could not be parsed: %s' %
|
output_api.PresubmitError(
|
||||||
|
'%s could not be parsed: %s' %
|
||||||
(affected_file.LocalPath(), parse_error)))
|
(affected_file.LocalPath(), parse_error)))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -819,8 +844,8 @@ def RunPythonTests(input_api, output_api):
|
||||||
return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
|
return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
|
||||||
|
|
||||||
excluded_files = [
|
excluded_files = [
|
||||||
# These tests should be run manually after webrtc_dashboard_upload target
|
# These tests should be run manually after webrtc_dashboard_upload
|
||||||
# has been built.
|
# target has been built.
|
||||||
'catapult_uploader_test.py',
|
'catapult_uploader_test.py',
|
||||||
'process_perf_results_test.py',
|
'process_perf_results_test.py',
|
||||||
]
|
]
|
||||||
|
@ -852,8 +877,8 @@ def CheckUsageOfGoogleProtobufNamespace(input_api, output_api,
|
||||||
files = []
|
files = []
|
||||||
pattern = input_api.re.compile(r'google::protobuf')
|
pattern = input_api.re.compile(r'google::protobuf')
|
||||||
proto_utils_path = os.path.join('rtc_base', 'protobuf_utils.h')
|
proto_utils_path = os.path.join('rtc_base', 'protobuf_utils.h')
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||||
x))
|
source_file_filter(x))
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
if f.LocalPath() in [proto_utils_path, 'PRESUBMIT.py']:
|
if f.LocalPath() in [proto_utils_path, 'PRESUBMIT.py']:
|
||||||
continue
|
continue
|
||||||
|
@ -865,8 +890,8 @@ def CheckUsageOfGoogleProtobufNamespace(input_api, output_api,
|
||||||
return [
|
return [
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
'Please avoid to use namespace `google::protobuf` directly.\n'
|
'Please avoid to use namespace `google::protobuf` directly.\n'
|
||||||
'Add a using directive in `%s` and include that header instead.' %
|
'Add a using directive in `%s` and include that header instead.'
|
||||||
proto_utils_path, files)
|
% proto_utils_path, files)
|
||||||
]
|
]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -919,12 +944,18 @@ def CommonChecks(input_api, output_api):
|
||||||
for f in input_api.AffectedFiles(include_deletes=False,
|
for f in input_api.AffectedFiles(include_deletes=False,
|
||||||
file_filter=python_file_filter)
|
file_filter=python_file_filter)
|
||||||
]
|
]
|
||||||
|
pylint_new_style = [
|
||||||
|
f for f in python_changed_files if f not in PYLINT_OLD_STYLE
|
||||||
|
]
|
||||||
|
pylint_old_style = [
|
||||||
|
f for f in python_changed_files if f in PYLINT_OLD_STYLE
|
||||||
|
]
|
||||||
|
if pylint_new_style:
|
||||||
results.extend(
|
results.extend(
|
||||||
input_api.canned_checks.RunPylint(
|
input_api.canned_checks.RunPylint(
|
||||||
input_api,
|
input_api,
|
||||||
output_api,
|
output_api,
|
||||||
files_to_check=python_changed_files,
|
files_to_check=pylint_new_style,
|
||||||
files_to_skip=(
|
files_to_skip=(
|
||||||
r'^base[\\\/].*\.py$',
|
r'^base[\\\/].*\.py$',
|
||||||
r'^build[\\\/].*\.py$',
|
r'^build[\\\/].*\.py$',
|
||||||
|
@ -940,11 +971,17 @@ def CommonChecks(input_api, output_api):
|
||||||
pylintrc='pylintrc',
|
pylintrc='pylintrc',
|
||||||
version='2.7'))
|
version='2.7'))
|
||||||
|
|
||||||
# TODO(bugs.webrtc.org/13606): talk/ is no more, so make below checks simpler?
|
if pylint_old_style:
|
||||||
# WebRTC can't use the presubmit_canned_checks.PanProjectChecks function
|
results.extend(
|
||||||
# since we need to have different license checks
|
input_api.canned_checks.RunPylint(input_api,
|
||||||
# in talk/ and webrtc/directories.
|
output_api,
|
||||||
# Instead, hand-picked checks are included below.
|
files_to_check=pylint_old_style,
|
||||||
|
pylintrc='pylintrc_old_style',
|
||||||
|
version='2.7'))
|
||||||
|
# TODO(bugs.webrtc.org/13606): talk/ is no more, so make below checks
|
||||||
|
# simpler. WebRTC can't use the presubmit_canned_checks.PanProjectChecks
|
||||||
|
# function since we need to have different license checks in talk/ and
|
||||||
|
# webrtc/directories. Instead, hand-picked checks are included below.
|
||||||
|
|
||||||
# .m and .mm files are ObjC files. For simplicity we will consider
|
# .m and .mm files are ObjC files. For simplicity we will consider
|
||||||
# .h files in ObjC subdirectories ObjC headers.
|
# .h files in ObjC subdirectories ObjC headers.
|
||||||
|
@ -1027,7 +1064,8 @@ def CommonChecks(input_api, output_api):
|
||||||
CheckNewlineAtTheEndOfProtoFiles(
|
CheckNewlineAtTheEndOfProtoFiles(
|
||||||
input_api, output_api, source_file_filter=non_third_party_sources))
|
input_api, output_api, source_file_filter=non_third_party_sources))
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckNoStreamUsageIsAdded(input_api, output_api, non_third_party_sources))
|
CheckNoStreamUsageIsAdded(input_api, output_api,
|
||||||
|
non_third_party_sources))
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckNoTestCaseUsageIsAdded(input_api, output_api,
|
CheckNoTestCaseUsageIsAdded(input_api, output_api,
|
||||||
non_third_party_sources))
|
non_third_party_sources))
|
||||||
|
@ -1038,7 +1076,8 @@ def CommonChecks(input_api, output_api):
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckAssertUsage(input_api, output_api, non_third_party_sources))
|
CheckAssertUsage(input_api, output_api, non_third_party_sources))
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckBannedAbslMakeUnique(input_api, output_api, non_third_party_sources))
|
CheckBannedAbslMakeUnique(input_api, output_api,
|
||||||
|
non_third_party_sources))
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
||||||
return results
|
return results
|
||||||
|
@ -1068,7 +1107,8 @@ def CheckApiDepsFileIsUpToDate(input_api, output_api):
|
||||||
path_tokens = [t for t in f.LocalPath().split(os.sep) if t]
|
path_tokens = [t for t in f.LocalPath().split(os.sep) if t]
|
||||||
if len(path_tokens) > 1:
|
if len(path_tokens) > 1:
|
||||||
if (path_tokens[0] not in dirs_to_skip and os.path.isdir(
|
if (path_tokens[0] not in dirs_to_skip and os.path.isdir(
|
||||||
os.path.join(input_api.PresubmitLocalPath(), path_tokens[0]))):
|
os.path.join(input_api.PresubmitLocalPath(),
|
||||||
|
path_tokens[0]))):
|
||||||
dirs_to_check.add(path_tokens[0])
|
dirs_to_check.add(path_tokens[0])
|
||||||
|
|
||||||
missing_include_rules = set()
|
missing_include_rules = set()
|
||||||
|
@ -1100,8 +1140,8 @@ def CheckApiDepsFileIsUpToDate(input_api, output_api):
|
||||||
|
|
||||||
|
|
||||||
def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
||||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
source_file_filter(f))
|
('.cc', '.h')) and source_file_filter(f))
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for f in input_api.AffectedFiles(include_deletes=False,
|
for f in input_api.AffectedFiles(include_deletes=False,
|
||||||
|
@ -1123,12 +1163,12 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
||||||
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||||
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
||||||
re.MULTILINE | re.DOTALL)
|
re.MULTILINE | re.DOTALL)
|
||||||
file_filter = lambda f: (f.LocalPath().endswith(('.h')) and
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
source_file_filter(f))
|
('.h')) and source_file_filter(f))
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(
|
file_filter = lambda x: (input_api.FilterSourceFile(x) and
|
||||||
x))
|
source_file_filter(x))
|
||||||
for f in input_api.AffectedSourceFiles(file_filter):
|
for f in input_api.AffectedSourceFiles(file_filter):
|
||||||
if not f.LocalPath().endswith('.h') or not 'sdk/objc' in f.LocalPath():
|
if not f.LocalPath().endswith('.h') or not 'sdk/objc' in f.LocalPath():
|
||||||
continue
|
continue
|
||||||
|
@ -1143,8 +1183,8 @@ def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||||
if len(files) > 0:
|
if len(files) > 0:
|
||||||
return [
|
return [
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() ' +
|
'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() '
|
||||||
'macro.\n\n' + 'For example:\n' +
|
+ 'macro.\n\n' + 'For example:\n' +
|
||||||
'RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
'RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||||
'RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
'RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||||
'Please fix the following files:', files)
|
'Please fix the following files:', files)
|
||||||
|
@ -1154,8 +1194,8 @@ def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||||
|
|
||||||
def CheckAssertUsage(input_api, output_api, source_file_filter):
|
def CheckAssertUsage(input_api, output_api, source_file_filter):
|
||||||
pattern = input_api.re.compile(r'\bassert\(')
|
pattern = input_api.re.compile(r'\bassert\(')
|
||||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h', '.m', '.mm'))
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
and source_file_filter(f))
|
('.cc', '.h', '.m', '.mm')) and source_file_filter(f))
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for f in input_api.AffectedFiles(include_deletes=False,
|
for f in input_api.AffectedFiles(include_deletes=False,
|
||||||
|
@ -1177,8 +1217,8 @@ def CheckAssertUsage(input_api, output_api, source_file_filter):
|
||||||
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
|
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
|
||||||
pattern = input_api.re.compile(r'^#include\s*"absl/memory/memory.h"',
|
pattern = input_api.re.compile(r'^#include\s*"absl/memory/memory.h"',
|
||||||
input_api.re.MULTILINE)
|
input_api.re.MULTILINE)
|
||||||
file_filter = lambda f: (f.LocalPath().endswith(('.cc', '.h')) and
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
source_file_filter(f))
|
('.cc', '.h')) and source_file_filter(f))
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
for f in input_api.AffectedFiles(include_deletes=False,
|
for f in input_api.AffectedFiles(include_deletes=False,
|
||||||
|
@ -1205,8 +1245,8 @@ def CheckChangeOnUpload(input_api, output_api):
|
||||||
results = []
|
results = []
|
||||||
results.extend(CommonChecks(input_api, output_api))
|
results.extend(CommonChecks(input_api, output_api))
|
||||||
results.extend(CheckGnGen(input_api, output_api))
|
results.extend(CheckGnGen(input_api, output_api))
|
||||||
results.extend(input_api.canned_checks.CheckGNFormatted(
|
results.extend(
|
||||||
input_api, output_api))
|
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@ -1218,7 +1258,8 @@ def CheckChangeOnCommit(input_api, output_api):
|
||||||
results.extend(
|
results.extend(
|
||||||
input_api.canned_checks.CheckChangeWasUploaded(input_api, output_api))
|
input_api.canned_checks.CheckChangeWasUploaded(input_api, output_api))
|
||||||
results.extend(
|
results.extend(
|
||||||
input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
|
input_api.canned_checks.CheckChangeHasDescription(
|
||||||
|
input_api, output_api))
|
||||||
results.extend(CheckChangeHasBugField(input_api, output_api))
|
results.extend(CheckChangeHasBugField(input_api, output_api))
|
||||||
results.extend(CheckCommitMessageBugEntry(input_api, output_api))
|
results.extend(CheckCommitMessageBugEntry(input_api, output_api))
|
||||||
results.extend(
|
results.extend(
|
||||||
|
@ -1238,8 +1279,8 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
||||||
exempt_paths = [re.escape(os.path.join('tools_webrtc', 'ios', 'SDK'))]
|
exempt_paths = [re.escape(os.path.join('tools_webrtc', 'ios', 'SDK'))]
|
||||||
|
|
||||||
with _AddToPath(
|
with _AddToPath(
|
||||||
input_api.os_path.join(input_api.PresubmitLocalPath(), 'tools_webrtc',
|
input_api.os_path.join(input_api.PresubmitLocalPath(),
|
||||||
'presubmit_checks_lib')):
|
'tools_webrtc', 'presubmit_checks_lib')):
|
||||||
from check_orphan_headers import GetBuildGnPathFromFilePath
|
from check_orphan_headers import GetBuildGnPathFromFilePath
|
||||||
from check_orphan_headers import IsHeaderInBuildGn
|
from check_orphan_headers import IsHeaderInBuildGn
|
||||||
|
|
||||||
|
@ -1249,13 +1290,14 @@ def CheckOrphanHeaders(input_api, output_api, source_file_filter):
|
||||||
if f.LocalPath().endswith('.h'):
|
if f.LocalPath().endswith('.h'):
|
||||||
file_path = os.path.abspath(f.LocalPath())
|
file_path = os.path.abspath(f.LocalPath())
|
||||||
root_dir = os.getcwd()
|
root_dir = os.getcwd()
|
||||||
gn_file_path = GetBuildGnPathFromFilePath(file_path, os.path.exists,
|
gn_file_path = GetBuildGnPathFromFilePath(file_path,
|
||||||
root_dir)
|
os.path.exists, root_dir)
|
||||||
in_build_gn = IsHeaderInBuildGn(file_path, gn_file_path)
|
in_build_gn = IsHeaderInBuildGn(file_path, gn_file_path)
|
||||||
if not in_build_gn:
|
if not in_build_gn:
|
||||||
results.append(
|
results.append(
|
||||||
output_api.PresubmitError(
|
output_api.PresubmitError(
|
||||||
error_msg.format(f.LocalPath(), os.path.relpath(gn_file_path))))
|
error_msg.format(f.LocalPath(),
|
||||||
|
os.path.relpath(gn_file_path))))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@ -1271,7 +1313,8 @@ def CheckNewlineAtTheEndOfProtoFiles(input_api, output_api,
|
||||||
with open(file_path) as f:
|
with open(file_path) as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
if len(lines) > 0 and not lines[-1].endswith('\n'):
|
if len(lines) > 0 and not lines[-1].endswith('\n'):
|
||||||
results.append(output_api.PresubmitError(error_msg.format(file_path)))
|
results.append(
|
||||||
|
output_api.PresubmitError(error_msg.format(file_path)))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@ -1360,7 +1403,8 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
||||||
filename = input_api.os_path.basename(f.LocalPath())
|
filename = input_api.os_path.basename(f.LocalPath())
|
||||||
if filename == 'DEPS':
|
if filename == 'DEPS':
|
||||||
virtual_depended_on_files.update(
|
virtual_depended_on_files.update(
|
||||||
_CalculateAddedDeps(input_api.os_path, '\n'.join(f.OldContents()),
|
_CalculateAddedDeps(input_api.os_path,
|
||||||
|
'\n'.join(f.OldContents()),
|
||||||
'\n'.join(f.NewContents())))
|
'\n'.join(f.NewContents())))
|
||||||
|
|
||||||
if not virtual_depended_on_files:
|
if not virtual_depended_on_files:
|
||||||
|
@ -1417,7 +1461,8 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
||||||
|
|
||||||
if unapproved_dependencies:
|
if unapproved_dependencies:
|
||||||
output_list = [
|
output_list = [
|
||||||
output('You need LGTM from owners of depends-on paths in DEPS that '
|
output(
|
||||||
|
'You need LGTM from owners of depends-on paths in DEPS that '
|
||||||
' were modified in this CL:\n %s' %
|
' were modified in this CL:\n %s' %
|
||||||
'\n '.join(sorted(unapproved_dependencies)))
|
'\n '.join(sorted(unapproved_dependencies)))
|
||||||
]
|
]
|
||||||
|
|
216
pylintrc_old_style
Normal file
216
pylintrc_old_style
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license
|
||||||
|
# that can be found in the LICENSE file in the root of the source
|
||||||
|
# tree. An additional intellectual property rights grant can be found
|
||||||
|
# in the file PATENTS. All contributing project authors may
|
||||||
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
# This file is mostly based on the contents of
|
||||||
|
# https://cs.chromium.org/chromium/tools/depot_tools/pylintrc
|
||||||
|
# and (since the above doesn't properly support naming style checks)
|
||||||
|
# https://cs.chromium.org/chromium/src/third_party/chromite/pylintrc
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
|
||||||
|
# Disable the message, report, category or checker with the given id(s).
|
||||||
|
# TODO(kjellander): Reduce this list to as small as possible.
|
||||||
|
disable=
|
||||||
|
E0611,
|
||||||
|
I0010,
|
||||||
|
I0011,
|
||||||
|
W0232,
|
||||||
|
C0413,
|
||||||
|
bad-continuation,
|
||||||
|
broad-except,
|
||||||
|
duplicate-code,
|
||||||
|
eval-used,
|
||||||
|
exec-used,
|
||||||
|
fixme,
|
||||||
|
import-error,
|
||||||
|
import-outside-toplevel,
|
||||||
|
missing-docstring,
|
||||||
|
no-init,
|
||||||
|
no-member,
|
||||||
|
too-few-public-methods,
|
||||||
|
too-many-ancestors,
|
||||||
|
too-many-arguments,
|
||||||
|
too-many-branches,
|
||||||
|
too-many-function-args,
|
||||||
|
too-many-instance-attributes,
|
||||||
|
too-many-lines,
|
||||||
|
too-many-locals,
|
||||||
|
too-many-public-methods,
|
||||||
|
too-many-return-statements,
|
||||||
|
too-many-statements,
|
||||||
|
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
|
||||||
|
# Don't write out full reports, just messages.
|
||||||
|
reports=no
|
||||||
|
|
||||||
|
|
||||||
|
[VARIABLES]
|
||||||
|
|
||||||
|
# Tells whether we should check for unused import in __init__ files.
|
||||||
|
init-import=no
|
||||||
|
|
||||||
|
# A regular expression matching the beginning of the name of dummy variables
|
||||||
|
# (i.e. not used).
|
||||||
|
dummy-variables-rgx=_|dummy
|
||||||
|
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
|
||||||
|
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||||
|
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||||
|
ignore-mixin-members=yes
|
||||||
|
|
||||||
|
# List of classes names for which member attributes should not be checked
|
||||||
|
# (useful for classes with attributes dynamically set).
|
||||||
|
ignored-classes=hashlib,numpy
|
||||||
|
|
||||||
|
|
||||||
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
|
notes=FIXME,XXX,TODO
|
||||||
|
|
||||||
|
|
||||||
|
[SIMILARITIES]
|
||||||
|
|
||||||
|
# Minimum lines number of a similarity.
|
||||||
|
min-similarity-lines=4
|
||||||
|
|
||||||
|
# Ignore comments when computing similarities.
|
||||||
|
ignore-comments=yes
|
||||||
|
|
||||||
|
# Ignore docstrings when computing similarities.
|
||||||
|
ignore-docstrings=yes
|
||||||
|
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
|
||||||
|
# Maximum number of characters on a single line.
|
||||||
|
max-line-length=80
|
||||||
|
|
||||||
|
# Maximum number of lines in a module
|
||||||
|
max-module-lines=1000
|
||||||
|
|
||||||
|
# Use four spaces for indents.
|
||||||
|
# indent-string=' '
|
||||||
|
|
||||||
|
|
||||||
|
[BASIC]
|
||||||
|
|
||||||
|
# List of builtins function names that should not be used, separated by a comma
|
||||||
|
bad-functions=map,filter,apply,input
|
||||||
|
|
||||||
|
# Regular expression which should only match correct module names
|
||||||
|
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct module level names
|
||||||
|
# (CAPS_WITH_UNDER)
|
||||||
|
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct class names
|
||||||
|
# (CapWords)
|
||||||
|
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct function names
|
||||||
|
# The Chromium standard is different than PEP-8, so we need to redefine this to
|
||||||
|
# only allow:
|
||||||
|
# - CapWords
|
||||||
|
# - main: Standard for main function.
|
||||||
|
function-rgx=([A-Z_][a-zA-Z0-9]{2,60}|main)$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct method names
|
||||||
|
# The Chromium standard is different than PEP-8, so we need to redefine this to
|
||||||
|
# only allow:
|
||||||
|
# - CapWords, starting with a capital letter. No underscores in function
|
||||||
|
# names. Can also have a "_" prefix (private method) or a "test" prefix
|
||||||
|
# (unit test).
|
||||||
|
# - Methods that look like __xyz__, which are used to do things like
|
||||||
|
# __init__, __del__, etc.
|
||||||
|
# - setUp, tearDown: For unit tests.
|
||||||
|
method-rgx=((_|test)?[A-Z][a-zA-Z0-9]{2,60}|__[a-z]+__|setUp|tearDown)$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct instance attribute names
|
||||||
|
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct argument names
|
||||||
|
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct variable names
|
||||||
|
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct list comprehension /
|
||||||
|
# generator expression variable names
|
||||||
|
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||||
|
|
||||||
|
# Good variable names which should always be accepted, separated by a comma
|
||||||
|
good-names=i,j,k,ex,Run,_
|
||||||
|
|
||||||
|
# Bad variable names which should always be refused, separated by a comma
|
||||||
|
bad-names=foo,bar,baz,toto,tutu,tata
|
||||||
|
|
||||||
|
# Regular expression which should only match functions or classes name which do
|
||||||
|
# not require a docstring
|
||||||
|
no-docstring-rgx=__.*__
|
||||||
|
|
||||||
|
|
||||||
|
[DESIGN]
|
||||||
|
|
||||||
|
# Maximum number of arguments for function / method
|
||||||
|
max-args=5
|
||||||
|
|
||||||
|
# Argument names that match this expression will be ignored. Default to name
|
||||||
|
# with leading underscore
|
||||||
|
ignored-argument-names=_.*
|
||||||
|
|
||||||
|
# Maximum number of locals for function / method body
|
||||||
|
max-locals=15
|
||||||
|
|
||||||
|
# Maximum number of return / yield for function / method body
|
||||||
|
max-returns=6
|
||||||
|
|
||||||
|
# Maximum number of branch for function / method body
|
||||||
|
max-branchs=12
|
||||||
|
|
||||||
|
# Maximum number of statements in function / method body
|
||||||
|
max-statements=50
|
||||||
|
|
||||||
|
# Maximum number of parents for a class (see R0901).
|
||||||
|
max-parents=7
|
||||||
|
|
||||||
|
# Maximum number of attributes for a class (see R0902).
|
||||||
|
max-attributes=7
|
||||||
|
|
||||||
|
# Minimum number of public methods for a class (see R0903).
|
||||||
|
min-public-methods=2
|
||||||
|
|
||||||
|
# Maximum number of public methods for a class (see R0904).
|
||||||
|
max-public-methods=20
|
||||||
|
|
||||||
|
|
||||||
|
[CLASSES]
|
||||||
|
|
||||||
|
# List of method names used to declare (i.e. assign) instance attributes.
|
||||||
|
defining-attr-methods=__init__,__new__,setUp
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a class method.
|
||||||
|
valid-classmethod-first-arg=cls
|
||||||
|
|
||||||
|
|
||||||
|
[IMPORTS]
|
||||||
|
|
||||||
|
# Deprecated modules which should not be used, separated by a comma
|
||||||
|
deprecated-modules=regsub,TERMIOS,Bastion,rexec
|
||||||
|
|
||||||
|
|
||||||
|
[EXCEPTIONS]
|
||||||
|
|
||||||
|
# Exceptions that will emit a warning when being caught. Defaults to
|
||||||
|
# "Exception"
|
||||||
|
overgeneral-exceptions=Exception
|
Loading…
Reference in a new issue