34
34
#
35
35
36
36
37
- # Ignore I202 "Additional newline in a section of imports." to accommodate
38
- # region tags in import blocks. Since we specify an explicit ignore, we also
39
- # have to explicitly ignore the list of default ignores:
40
- # `E121,E123,E126,E226,E24,E704,W503,W504` as shown by `flake8 --help`.
41
37
def _determine_local_import_names (start_dir ):
42
38
"""Determines all import names that should be considered "local".
43
39
@@ -54,13 +50,23 @@ def _determine_local_import_names(start_dir):
54
50
]
55
51
56
52
53
+ # Linting with flake8.
54
+ #
55
+ # We ignore the following rules:
56
+ # E203: whitespace before ‘:’
57
+ # E266: too many leading ‘#’ for block comment
58
+ # E501: line too long
59
+ # I202: Additional newline in a section of imports
60
+ #
61
+ # We also need to specify the rules which are ignored by default:
62
+ # ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
57
63
FLAKE8_COMMON_ARGS = [
58
64
"--show-source" ,
59
65
"--builtin=gettext" ,
60
66
"--max-complexity=20" ,
61
67
"--import-order-style=google" ,
62
68
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py" ,
63
- "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I100,I201, I202" ,
69
+ "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202" ,
64
70
"--max-line-length=88" ,
65
71
]
66
72
@@ -142,11 +148,12 @@ def _get_repo_root():
142
148
def readmegen (session , path ):
143
149
"""(Re-)generates the readme for a sample."""
144
150
session .install ("jinja2" , "pyyaml" )
151
+ dir_ = os .path .dirname (path )
145
152
146
- if os .path .exists (os .path .join (path , "requirements.txt" )):
147
- session .install ("-r" , os .path .join (path , "requirements.txt" ))
153
+ if os .path .exists (os .path .join (dir_ , "requirements.txt" )):
154
+ session .install ("-r" , os .path .join (dir_ , "requirements.txt" ))
148
155
149
- in_file = os .path .join (path , "README.rst.in" )
156
+ in_file = os .path .join (dir_ , "README.rst.in" )
150
157
session .run (
151
158
"python" , _get_repo_root () + "/scripts/readme-gen/readme_gen.py" , in_file
152
159
)
0 commit comments