Skip to content

Commit 1c47b64

Browse files
A. Unique TensorFlowertensorflower-gardener
authored andcommitted
Fix a few pylint warnings.
Change: 122439260
1 parent a530860 commit 1c47b64

3 files changed

Lines changed: 29 additions & 19 deletions

File tree

tensorflow/python/client/client_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16-
# pylint: disable=unused-import
1716
"""This library contains classes for launching graphs and executing operations.
1817
1918
The [basic usage](../../get_started/index.md#basic-usage) guide has
@@ -51,6 +50,7 @@
5150
from __future__ import division
5251
from __future__ import print_function
5352

53+
# pylint: disable=unused-import
5454
from tensorflow.python.client.session import InteractiveSession
5555
from tensorflow.python.client.session import Session
5656

tensorflow/python/framework/docs.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import inspect
2626
import os
2727
import re
28-
import sys
2928

3029

3130
_arg_re = re.compile(" *([*]{0,2}[a-zA-Z][a-zA-Z0-9_]*):")
@@ -88,8 +87,8 @@ def write_markdown_to_file(self, f):
8887
for filename, library in self._filename_to_library_map:
8988
sorted_names = sorted(library.mentioned, key=lambda x: (str.lower(x), x))
9089
member_names = [n for n in sorted_names if n in self._members]
91-
# TODO: This is a hack that should be removed as soon as the website code
92-
# allows it.
90+
# TODO(wicke): This is a hack that should be removed as soon as the
91+
# website code allows it.
9392
full_filename = self._path_prefix + filename
9493
links = ["[`%s`](%s#%s)" % (name, full_filename, anchor_f(name))
9594
for name in member_names]
@@ -109,6 +108,9 @@ def collect_members(module_to_name, exclude=()):
109108
110109
Returns:
111110
Dictionary mapping name to (fullname, member) pairs.
111+
112+
Raises:
113+
RuntimeError: if we can not resolve a name collision.
112114
"""
113115
members = {}
114116
for module, module_name in module_to_name.items():
@@ -117,7 +119,7 @@ def collect_members(module_to_name, exclude=()):
117119
if ((inspect.isfunction(member) or inspect.isclass(member)) and
118120
not _always_drop_symbol_re.match(name) and
119121
(all_names is None or name in all_names)):
120-
fullname = '%s.%s' % (module_name, name)
122+
fullname = "%s.%s" % (module_name, name)
121123
if fullname in exclude:
122124
continue
123125
if name in members:
@@ -209,7 +211,7 @@ def exclude_symbols(self):
209211
"""Set of excluded symbols."""
210212
return self._exclude_symbols
211213

212-
def _should_include_member(self, name, member):
214+
def _should_include_member(self, name):
213215
"""Returns True if this member should be included in the document."""
214216
# Always exclude symbols matching _always_drop_symbol_re.
215217
if _always_drop_symbol_re.match(name):
@@ -245,7 +247,7 @@ def get_class_members(self, cls_name, cls):
245247
if not (is_method or isinstance(member, property)):
246248
continue
247249
if ((is_method and member.__name__ == "__init__")
248-
or self._should_include_member(name, member)):
250+
or self._should_include_member(name)):
249251
yield name, ("%s.%s" % (cls_name, name), member)
250252

251253
def set_functions_and_classes_dir(self, dirname):
@@ -430,7 +432,8 @@ def _write_docstring_markdown_to_file(self, f, prefix, docstring, members,
430432
elif name in imports:
431433
self._write_module_markdown_to_file(f, imports[name])
432434
else:
433-
raise ValueError("%s: unknown member `%s`" % (self._title, name))
435+
raise ValueError("%s: unknown member `%s`, markdown=`%s`." % (
436+
self._title, name, l))
434437
else:
435438
print(l, file=f)
436439

@@ -439,9 +442,8 @@ def _write_class_markdown_to_file(self, f, name, cls):
439442
440443
Args:
441444
f: File to write to.
442-
prefix: Prefix for names.
443-
cls: class object.
444445
name: name to use.
446+
cls: class object.
445447
"""
446448
# Build the list of class methods to document.
447449
methods = dict(self.get_class_members(name, cls))
@@ -527,26 +529,26 @@ def write_other_members(self, f, catch_all=False):
527529
def assert_no_leftovers(self):
528530
"""Generate an error if there are leftover members."""
529531
leftovers = []
530-
for name in self._members.keys():
532+
for name in self._members:
531533
if name in self._members and name not in self._documented:
532534
leftovers.append(name)
533535
if leftovers:
534536
raise RuntimeError("%s: undocumented members: %s" %
535537
(self._title, ", ".join(leftovers)))
536538

537539

538-
def write_libraries(dir, libraries):
540+
def write_libraries(output_dir, libraries):
539541
"""Write a list of libraries to disk.
540542
541543
Args:
542-
dir: Output directory.
544+
output_dir: Output directory.
543545
libraries: List of (filename, library) pairs.
544546
"""
545-
files = [open(os.path.join(dir, k), "w") for k, _ in libraries]
547+
files = [open(os.path.join(output_dir, k), "w") for k, _ in libraries]
546548

547549
# Set the directory in which to save individual class and function md files,
548550
# creating it if it doesn't exist.
549-
indiv_dir = os.path.join(dir, _indiv_dir)
551+
indiv_dir = os.path.join(output_dir, _indiv_dir)
550552
if not os.path.exists(indiv_dir):
551553
os.makedirs(indiv_dir)
552554

tensorflow/python/framework/gen_docs_combined.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
import tensorflow as tf
2525

26+
from tensorflow.python.client import client_lib
2627
from tensorflow.python.framework import docs
2728
from tensorflow.python.framework import framework_lib
28-
from tensorflow.python.client import client_lib
2929

3030

3131
tf.flags.DEFINE_string("out_dir", None,
@@ -60,8 +60,16 @@ def get_module_to_name():
6060

6161

6262
def all_libraries(module_to_name, members, documented):
63-
# A list of (filename, docs.Library) pairs representing the individual files
64-
# that we want to create.
63+
"""Make a list of the individual files that we want to create.
64+
65+
Args:
66+
module_to_name: Dictionary mapping modules to short names.
67+
members: Dictionary mapping member name to (fullname, member).
68+
documented: Set of documented names to update.
69+
70+
Returns:
71+
List of (filename, docs.Library) pairs.
72+
"""
6573
def library(name, title, module=None, **args):
6674
if module is None:
6775
module = sys.modules["tensorflow.python.ops" +
@@ -133,7 +141,7 @@ def library(name, title, module=None, **args):
133141
library("contrib.learn", "Learn (contrib)", tf.contrib.learn),
134142
library("contrib.metrics", "Metrics (contrib)", tf.contrib.metrics),
135143
library("contrib.util", "Utilities (contrib)", tf.contrib.util),
136-
library("contrib.copy_graph", "Copying Graph Elements (contrib)",
144+
library("contrib.copy_graph", "Copying Graph Elements (contrib)",
137145
tf.contrib.copy_graph),
138146
]
139147

0 commit comments

Comments
 (0)