text stringlengths 0 828 |
|---|
test_signatures = re.compile(""^({0})"".format(""|"".join(signatures))) |
test_alt_signatures = re.compile(""^({0})"".format(""|"".join(alt_signatures))) |
for i, line in lines: |
if signatures and test_signatures.search(line): |
if line.endswith("".""): |
errors.append((""M191"", i)) |
if not alt_signatures or not test_alt_signatures.search(line): |
matching.append(line) |
else: |
errors.append((""M102"", i)) |
if not matching: |
errors.append((""M101"", 1)) |
errors.append((""M100"", 1)) |
elif len(matching) < min_reviewers: |
pattern = re.compile('|'.join(map(lambda x: '<' + re.escape(x) + '>', |
trusted))) |
trusted_matching = list(filter(None, map(pattern.search, matching))) |
if len(trusted_matching) == 0: |
errors.append((""M100"", 1)) |
return errors" |
1659,"def check_message(message, **kwargs): |
""""""Check the message format. |
Rules: |
- the first line must start by a component name |
- and a short description (52 chars), |
- then bullet points are expected |
- and finally signatures. |
:param components: compontents, e.g. ``('auth', 'utils', 'misc')`` |
:type components: `list` |
:param signatures: signatures, e.g. ``('Signed-off-by', 'Reviewed-by')`` |
:type signatures: `list` |
:param alt_signatures: alternative signatures, e.g. ``('Tested-by',)`` |
:type alt_signatures: `list` |
:param trusted: optional list of reviewers, e.g. ``('john.doe@foo.org',)`` |
:type trusted: `list` |
:param max_length: optional maximum line length (by default: 72) |
:type max_length: int |
:param max_first_line: optional maximum first line length (by default: 50) |
:type max_first_line: int |
:param allow_empty: optional way to allow empty message (by default: False) |
:type allow_empty: bool |
:return: errors sorted by line number |
:rtype: `list` |
"""""" |
if kwargs.pop(""allow_empty"", False): |
if not message or message.isspace(): |
return [] |
lines = re.split(r""\r\n|\r|\n"", message) |
errors = _check_1st_line(lines[0], **kwargs) |
err, signature_lines = _check_bullets(lines, **kwargs) |
errors += err |
errors += _check_signatures(signature_lines, **kwargs) |
def _format(code, lineno, args): |
return ""{0}: {1} {2}"".format(lineno, |
code, |
_messages_codes[code].format(*args)) |
return list(map(lambda x: _format(x[0], x[1], x[2:]), |
sorted(errors, key=lambda x: x[0])))" |
1660,"def _register_pyflakes_check(): |
""""""Register the pyFlakes checker into PEP8 set of checks."""""" |
from flake8_isort import Flake8Isort |
from flake8_blind_except import check_blind_except |
# Resolving conflicts between pep8 and pyflakes. |
codes = { |
""UnusedImport"": ""F401"", |
""ImportShadowedByLoopVar"": ""F402"", |
""ImportStarUsed"": ""F403"", |
""LateFutureImport"": ""F404"", |
""Redefined"": ""F801"", |
""RedefinedInListComp"": ""F812"", |
""UndefinedName"": ""F821"", |
""UndefinedExport"": ""F822"", |
""UndefinedLocal"": ""F823"", |
""DuplicateArgument"": ""F831"", |
""UnusedVariable"": ""F841"", |
} |
for name, obj in vars(pyflakes.messages).items(): |
if name[0].isupper() and obj.message: |
obj.tpl = ""{0} {1}"".format(codes.get(name, ""F999""), obj.message) |
pep8.register_check(_PyFlakesChecker, codes=['F']) |
# FIXME parser hack |
parser = pep8.get_parser('', '') |
Flake8Isort.add_options(parser) |
options, args = parser.parse_args([]) |
# end of hack |
pep8.register_check(Flake8Isort, codes=['I']) |
pep8.register_check(check_blind_except, codes=['B90'])" |
1661,"def is_file_excluded(filename, excludes): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.