GeezerVison is showing github.com — Make "arc lint" use Flake8. Fix lint errors. · JavaScriptBach/stone@06dac6c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/.phutil_module_cache |
Collapse file Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<?php | | 2 | + | | 3 | +phutil_register_library('babel-arcanist-utils', __FILE__); |
Collapse file Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<?php | | 2 | + | | 3 | +/** | | 4 | + * This file is automatically generated. Use 'arc liberate' to rebuild it. | | 5 | + * | | 6 | + * @generated | | 7 | + * @phutil-library-version 2 | | 8 | + */ | | 9 | +phutil_register_library_map(array( | | 10 | + '__library_version__' => 2, | | 11 | + 'class' => array( | | 12 | + 'BabelLintEngine' => 'lint/BabelLintEngine.php', | | 13 | + ), | | 14 | + 'function' => array(), | | 15 | + 'xmap' => array( | | 16 | + 'BabelLinter' => 'ArcanistLintEngine', | | 17 | + ), | | 18 | +)); |
Collapse file Copy file name to clipboard +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<?php | | 2 | + | | 3 | +final class BabelLintEngine extends ArcanistLintEngine { | | 4 | + | | 5 | + public function buildLinters() { | | 6 | + $flake8 = new ArcanistFlake8Linter(); | | 7 | + | | 8 | + $pythonPaths = array(); | | 9 | + foreach ($this->getPaths() as $path) { | | 10 | + if (!self::endsWith($path, ".py")) continue; // Only include Python files. | | 11 | + if (self::startsWith($path, "example/api/")) continue; // Old crufty stuff. | | 12 | + \array_push($pythonPaths, $path); | | 13 | + } | | 14 | + $flake8->setPaths($pythonPaths); | | 15 | + | | 16 | + return array( | | 17 | + "flake8" => $flake8, | | 18 | + ); | | 19 | + } | | 20 | + | | 21 | + public static function startsWith($haystack, $needle) { | | 22 | + return \substr($haystack, 0, strlen($needle)) === $needle; | | 23 | + } | | 24 | + | | 25 | + public static function endsWith($haystack, $needle) { | | 26 | + return \substr($haystack, \strlen($haystack) - \strlen($needle)) === $needle; | | 27 | + } | | 28 | +} |
Collapse file Copy file name to clipboardExpand all lines: .arcconfig +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | "conduit_uri" : "https://tails.corp.dropbox.com/api/", | 4 | 4 | "copyright_holder" : "Dropbox", | 5 | 5 | "repository.callsign": "BABEL", | 6 | | - "immutable_history": false | | 6 | + "immutable_history": false, | | 7 | + | | 8 | + "lint_engine": "BabelLintEngine", | | 9 | + | | 10 | + "phutil_libraries": { | | 11 | + "babel-arcanist-utils": ".arc_lib" | | 12 | + } | 7 | 13 | } |
Collapse file Copy file name to clipboardExpand all lines: babelapi/babel/lexer.py +11-9Lines changed: 11 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,10 +55,12 @@ def token(self): | 55 | 55 | else: | 56 | 56 | if r is None and self.cur_indent > 0: | 57 | 57 | if self.last_token and self.last_token.type not in ('NEWLINE', 'LINE'): | 58 | | - newline_token = self._create_token('NEWLINE', '\n', self.lex.lineno, self.lex.lexpos) | | 58 | + newline_token = self._create_token('NEWLINE', '\n', self.lex.lineno, | | 59 | + self.lex.lexpos) | 59 | 60 | self.tokens_queue.append(newline_token) | 60 | 61 | dedent_count = self.cur_indent / 4 | 61 | | - dedent_token = self._create_token('DEDENT', '\t', self.lex.lineno, self.lex.lexpos) | | 62 | + dedent_token = self._create_token('DEDENT', '\t', self.lex.lineno, | | 63 | + self.lex.lexpos) | 62 | 64 | self.tokens_queue.extend([dedent_token] * dedent_count) | 63 | 65 |
| 64 | 66 | self.cur_indent = 0 | @@ -90,11 +92,11 @@ def test(self, data): | 90 | 92 |
| 91 | 93 | # List of token names | 92 | 94 | tokens = ( | 93 | | - 'ID', | 94 | | - 'KEYWORD', | 95 | | - 'PATH', | 96 | | - 'PIPE', | 97 | | - 'DOT', | | 95 | + 'ID', | | 96 | + 'KEYWORD', | | 97 | + 'PATH', | | 98 | + 'PIPE', | | 99 | + 'DOT', | 98 | 100 | ) | 99 | 101 |
| 100 | 102 | # Whitespace tokens | @@ -128,8 +130,8 @@ def test(self, data): | 128 | 130 |
| 129 | 131 | # Regular expression rules for simple tokens | 130 | 132 | t_DOT = r'\.' | 131 | | - t_LPAR = r'\(' | 132 | | - t_RPAR = r'\)' | | 133 | + t_LPAR = r'\(' | | 134 | + t_RPAR = r'\)' | 133 | 135 | t_EQ = r'=' | 134 | 136 | t_COMMA = r',' | 135 | 137 | t_PIPE = r'\|' | |
Collapse file Copy file name to clipboardExpand all lines: babelapi/babel/parser.py +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -385,7 +385,10 @@ def p_coverage(self, p): | 385 | 385 | p[0] = p[2] | 386 | 386 |
| 387 | 387 | def p_struct(self, p): | 388 | | - 'struct : STRUCT ID inheritance coverage NEWLINE INDENT docsection field_list example_list DEDENT' | | 388 | + """ | | 389 | + struct : STRUCT ID inheritance coverage NEWLINE \ | | 390 | + INDENT docsection field_list example_list DEDENT | | 391 | + """ | 389 | 392 | p[0] = BabelTypeDef(p.lineno(1), p.lexpos(1), p[1], p[2], extends=p[3], coverage=p[4]) | 390 | 393 | if p[7]: | 391 | 394 | p[0].set_doc(p[7]) | |
Collapse file Copy file name to clipboardExpand all lines: babelapi/compiler.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | import inspect | 5 | 5 | import os | 6 | 6 | import re | 7 | | -import sys | 8 | 7 | import shutil | 9 | 8 |
| 10 | 9 | from babelapi.generator import Generator | |
Collapse file Copy file name to clipboardExpand all lines: babelapi/data_type.py +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -642,7 +642,7 @@ def get_example(self, label): | 642 | 642 | raise Exception('No example with label %r for subtype ' | 643 | 643 | '%r' % (label, field.data_type.name)) | 644 | 644 | elif (isinstance(field.data_type, List) and | 645 | | - isinstance(field.data_type.data_type, CompositeType)): | | 645 | + isinstance(field.data_type.data_type, CompositeType)): | 646 | 646 | example_copy[field.name] = [field.data_type.data_type.get_example(label)] | 647 | 647 | return example_copy | 648 | 648 |
| @@ -704,9 +704,8 @@ def has_example(self, label): | 704 | 704 | def get_example(self, label): | 705 | 705 | for field in self.fields: | 706 | 706 | if (isinstance(field, Field) | 707 | | - and isinstance(field.data_type, CompositeType) | 708 | | - and field.data_type.has_example(label)): | 709 | | - | | 707 | + and isinstance(field.data_type, CompositeType) | | 708 | + and field.data_type.has_example(label)): | 710 | 709 | return {field.name: field.data_type.get_example(label)} | 711 | 710 | else: | 712 | 711 | # Fallback to checking for direct symbols | |
Collapse file Copy file name to clipboardExpand all lines: babelapi/lang/ruby.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,8 @@ def format_type(self, data_type): | 40 | 40 | return RubyTargetLanguage._type_table.get(data_type.__class__, data_type.name) | 41 | 41 |
| 42 | 42 | def format_obj(self, o): | 43 | | - assert not isinstance(o, dict), "Bad argument to format_obj: pprint's dict formatting is not valid Ruby." | | 43 | + assert not isinstance(o, dict), \ | | 44 | + "Bad argument to format_obj: pprint's dict formatting is not valid Ruby." | 44 | 45 | if o is True: | 45 | 46 | return 'true' | 46 | 47 | if o is False: | |
|