Skip to content

Commit 18e1785

Browse files
committed
Preparing PyLint for subpackage breakup.
1 parent 0142350 commit 18e1785

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

scripts/run_pylint.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
IGNORED_DIRECTORIES = [
3434
os.path.join('google', 'cloud', 'bigtable', '_generated'),
3535
os.path.join('google', 'cloud', 'datastore', '_generated'),
36-
'scripts/verify_included_modules.py',
3736
]
3837
IGNORED_FILES = [
3938
os.path.join('docs', 'conf.py'),
39+
]
40+
IGNORED_POSTFIXES = [
41+
os.path.join('google', '__init__.py'),
42+
os.path.join('google', 'cloud', '__init__.py'),
4043
'setup.py',
4144
]
4245
SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -113,6 +116,9 @@ def make_test_rc(base_rc_filename, additions_dict,
113116

114117
def valid_filename(filename):
115118
"""Checks if a file is a Python file and is not ignored."""
119+
for postfix in IGNORED_POSTFIXES:
120+
if filename.endswith(postfix):
121+
return False
116122
for directory in IGNORED_DIRECTORIES:
117123
if filename.startswith(directory):
118124
return False

scripts/verify_included_modules.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
'google.cloud.vision.__init__',
5858
'google.cloud.vision.fixtures',
5959
])
60+
PACKAGES = (
61+
'',
62+
)
6063

6164

6265
class SphinxApp(object):
@@ -120,8 +123,8 @@ def get_public_modules(path, base_package=None):
120123
return result
121124

122125

123-
def main(build_root='_build'):
124-
"""Main script to verify modules included.
126+
def verify_modules(build_root='_build'):
127+
"""Verify modules included.
125128
126129
:type build_root: str
127130
:param build_root: The root of the directory where docs are built into.
@@ -134,10 +137,12 @@ def main(build_root='_build'):
134137
object_inventory_relpath)
135138
sphinx_mods = set(inventory['py:module'].keys())
136139

137-
library_dir = os.path.join(BASE_DIR, 'google', 'cloud')
138-
public_mods = get_public_modules(library_dir,
139-
base_package='google.cloud')
140-
public_mods = set(public_mods)
140+
public_mods = set()
141+
for package in PACKAGES:
142+
library_dir = os.path.join(BASE_DIR, package, 'google', 'cloud')
143+
package_mods = get_public_modules(library_dir,
144+
base_package='google.cloud')
145+
public_mods.update(package_mods)
141146

142147
if not sphinx_mods <= public_mods:
143148
unexpected_mods = sphinx_mods - public_mods
@@ -172,7 +177,12 @@ def get_parser():
172177
return parser
173178

174179

175-
if __name__ == '__main__':
180+
def main():
181+
"""Main script to verify modules included."""
176182
parser = get_parser()
177183
args = parser.parse_args()
178-
main(build_root=args.build_root)
184+
verify_modules(build_root=args.build_root)
185+
186+
187+
if __name__ == '__main__':
188+
main()

0 commit comments

Comments
 (0)