Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-23173: Change W504 to W503 and fix flake8 warnings #115

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 27 additions & 27 deletions python/lsst/daf/persistence/butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
RepositoryArgs, listify, setify, sequencify, doImport, ButlerComposite, genericAssembler, \
genericDisassembler, PosixStorage, ParentsMismatch

preinitedMapperWarning = ("Passing an instantiated mapper into " +
"Butler.__init__ will prevent Butler from passing " +
"parentRegistry or repositoryCfg information to " +
"the mapper, which is done only at init time. " +
"It is better to pass a importable string or " +
preinitedMapperWarning = ("Passing an instantiated mapper into "
"Butler.__init__ will prevent Butler from passing "
"parentRegistry or repositoryCfg information to "
"the mapper, which is done only at init time. "
"It is better to pass a importable string or "
"class object.")


Expand Down Expand Up @@ -142,11 +142,11 @@ def __repr__(self):
"repoArgs={}"
"cfg={!r},"
"cfgOrigin={},"
"cfgRoot={}," +
"cfgRoot={},"
"repo={},"
"parentRepoDatas={}," +
"parentRepoDatas={},"
"isV1Repository={},"
"role={}," +
"role={},"
"parentRegistry={})").format(
self.__class__.__name__,
id(self),
Expand Down Expand Up @@ -594,7 +594,7 @@ def _processInputArguments(self, root=None, mapper=None, inputs=None, outputs=No
mapperArgs=mapperArgs or None)
elif root or mapper or mapperArgs:
raise RuntimeError(
'Butler version 1 API (root, mapper, **mapperArgs) may ' +
'Butler version 1 API (root, mapper, **mapperArgs) may '
'not be used with version 2 API (inputs, outputs)')
self.datasetTypeAliasDict = {}

Expand Down Expand Up @@ -623,8 +623,8 @@ def _processInputArguments(self, root=None, mapper=None, inputs=None, outputs=No
raise RuntimeError("The mode of an output should be writable.")
# check for class instances in args.mapper (not allowed)
for args in inputs + outputs:
if (args.mapper and not isinstance(args.mapper, str) and
not inspect.isclass(args.mapper)):
if (args.mapper and not isinstance(args.mapper, str)
and not inspect.isclass(args.mapper)):
self.log.warn(preinitedMapperWarning)
# if the output is readable, there must be only one output:
for o in outputs:
Expand All @@ -638,13 +638,13 @@ def _processInputArguments(self, root=None, mapper=None, inputs=None, outputs=No
# output, to the command line parser.
def inputIsInOutputs(inputArgs, outputArgsList):
for o in outputArgsList:
if ('r' in o.mode and
o.root == inputArgs.root and
o.mapper == inputArgs.mapper and
o.mapperArgs == inputArgs.mapperArgs and
o.tags == inputArgs.tags and
o.policy == inputArgs.policy):
self.log.debug(("Input repositoryArgs {} is also listed in outputs as readable; " +
if ('r' in o.mode
and o.root == inputArgs.root
and o.mapper == inputArgs.mapper
and o.mapperArgs == inputArgs.mapperArgs
and o.tags == inputArgs.tags
and o.policy == inputArgs.policy):
self.log.debug(("Input repositoryArgs {} is also listed in outputs as readable; "
"throwing away the input.").format(inputArgs))
return True
return False
Expand Down Expand Up @@ -782,7 +782,7 @@ def cfgMatchesArgs(args, cfg):
if 'w' in repoData.repoArgs.mode:
# if it's an output repository, the RepositoryArgs must match the existing cfg.
if not cfgMatchesArgs(repoData.repoArgs, cfg):
raise RuntimeError(("The RepositoryArgs and RepositoryCfg must match for writable " +
raise RuntimeError(("The RepositoryArgs and RepositoryCfg must match for writable "
"repositories, RepositoryCfg:{}, RepositoryArgs:{}").format(
cfg, repoData.repoArgs))
repoData.setCfg(cfg=cfg, origin='existing', root=repoData.repoArgs.cfgRoot,
Expand Down Expand Up @@ -834,8 +834,8 @@ def _addParents(self, repoDataList):
isOldButlerRepository = False
repoParentCfg = repoParent
cfgOrigin = 'nested'
if (parentIdxInRepoDataList < len(repoDataList) and
repoDataList[parentIdxInRepoDataList].cfg == repoParentCfg):
if (parentIdxInRepoDataList < len(repoDataList)
and repoDataList[parentIdxInRepoDataList].cfg == repoParentCfg):
continue
args = RepositoryArgs(cfgRoot=repoParentCfg.root, mode='r')
role = 'input' if repoData.role == 'output' else 'parent'
Expand Down Expand Up @@ -891,7 +891,7 @@ def getIOParents(ofRepoData, repoDataList):
try:
repoData.cfg.extendParents(parents)
except ParentsMismatch as e:
raise RuntimeError(("Inputs of this Butler:{} do not match parents of existing " +
raise RuntimeError(("Inputs of this Butler:{} do not match parents of existing "
"writable cfg:{} (ParentMismatch exception: {}").format(
parents, repoData.cfg.parents, e))

Expand All @@ -918,7 +918,7 @@ def _setDefaultMapper(self, repoDataList):
if len(mappers) != 1:
inputs = [rd for rd in repoDataList if rd.role == 'input']
raise RuntimeError(
("No default mapper could be established from inputs:{} and no mapper specified " +
("No default mapper could be established from inputs:{} and no mapper specified "
"for outputs:{}").format(inputs, needyOutputs))
defaultMapper = mappers.pop()
for repoData in needyOutputs:
Expand Down Expand Up @@ -1013,8 +1013,8 @@ def _convertV1Args(self, root, mapper, mapperArgs):
tuple
(inputs, outputs) - values to be used for inputs and outputs in Butler.__init__
"""
if (mapper and not isinstance(mapper, str) and
not inspect.isclass(mapper)):
if (mapper and not isinstance(mapper, str)
and not inspect.isclass(mapper)):
self.log.warn(preinitedMapperWarning)
inputs = None
if root is None:
Expand Down Expand Up @@ -1351,8 +1351,8 @@ def _locate(self, datasetType, dataId, write):
# If a location was found but the location does not exist, keep looking in input
# repositories (the registry may have had enough data for a lookup even thought the object
# exists in a different repository.)
if (isinstance(location, ButlerComposite) or hasattr(location, 'bypass') or
location.repository.exists(location)):
if (isinstance(location, ButlerComposite) or hasattr(location, 'bypass')
or location.repository.exists(location)):
return location
else:
try:
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/daf/persistence/posixStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ def v1RepoExists(root):
True if the repository at root exists, else False.
"""
return os.path.exists(root) and (
os.path.exists(os.path.join(root, "registry.sqlite3")) or
os.path.exists(os.path.join(root, "_mapper")) or
os.path.exists(os.path.join(root, "_parent"))
os.path.exists(os.path.join(root, "registry.sqlite3"))
or os.path.exists(os.path.join(root, "_mapper"))
or os.path.exists(os.path.join(root, "_parent"))
)

def copyFile(self, fromLocation, toLocation):
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/daf/persistence/repositoryCfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def extend(self, other):
(If this RepositoryCfg's parents can not be extended with the parents of the other repository,
extendParents will raise).
"""
if (self.root != other.root or
self.mapper != other.mapper or
self.mapperArgs != other.mapperArgs or
self.policy != other.policy):
if (self.root != other.root
or self.mapper != other.mapper
or self.mapperArgs != other.mapperArgs
or self.policy != other.policy):
raise RuntimeError("{} can not be extended with cfg:{}".format(self, other))
self.extendParents(other.parents)

Expand Down Expand Up @@ -176,7 +176,7 @@ def extendParents(self, newParents):
else:
doRaise = True
if doRaise:
raise ParentsMismatch(("The beginning of the passed-in parents list: {} does not match the " +
raise ParentsMismatch(("The beginning of the passed-in parents list: {} does not match the "
"existing parents list in this RepositoryCfg: {}").format(
newParents, self._parents))

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/persistence/storageInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def registerFormatters(cls, formatable, readFormatter=None, writeFormatter=None)
"""
def register(formatable, formatter, formatters, storageInterface):
if formatable in formatters:
raise RuntimeError(("Registration of second formatter {} for formattable {} in " +
raise RuntimeError(("Registration of second formatter {} for formattable {} in "
" storageInterface {}").format(formatter, formatable, storageInterface))
formatters[formatable] = formatter

Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[flake8]
max-line-length = 110
ignore = E133, E226, E228, N802, N803, N806, N812, N815, N816, W504
ignore = E133, E226, E228, N802, N803, N806, N812, N815, N816, W503
exclude = __init__.py

[tool:pytest]
addopts = --flake8
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W504
flake8-ignore = E133 E226 E228 N802 N803 N806 N812 N815 N816 W503