Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Jan 24, 2019
1 parent daa0f55 commit c722b8e
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion conda/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def confirm_yn(message="Proceed", default='yes', dry_run=NULL):
return True
try:
choice = confirm(message=message, choices=('yes', 'no'), default=default)
except KeyboardInterrupt as e: # pragma: no cover
except KeyboardInterrupt: # pragma: no cover
from ..exceptions import CondaSystemExit
raise CondaSystemExit("\nOperation aborted. Exiting.")
if choice == 'no':
Expand Down
1 change: 1 addition & 0 deletions conda/cli/conda_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def do_call(args, parser):
# func_name should always be 'execute'
from importlib import import_module
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])

exit_code = getattr(module, func_name)(args, parser)
return exit_code

Expand Down
2 changes: 1 addition & 1 deletion conda/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def main(*args, **kwargs):
import conda.cli.activate as activate
activate.main()
return
except Exception as e:
except Exception:
_, exc_val, exc_tb = sys.exc_info()
init_loggers()
from ..exceptions import ExceptionHandler
Expand Down
19 changes: 11 additions & 8 deletions conda/cli/main_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from collections import defaultdict
import fnmatch
from logging import getLogger
from os import listdir, lstat, walk
from os import listdir, lstat, walk, unlink
from os.path import getsize, isdir, join, exists
import sys

from ..base.constants import CONDA_TARBALL_EXTENSION
from ..common.constants import CONDA_TEMP_EXTENSION
from ..base.context import context

log = getLogger(__name__)
Expand Down Expand Up @@ -205,15 +207,16 @@ def rm_rf_pkgs_dirs():
def clean_tmp_files(path=None):
if not path:
path = sys.prefix
for root, dirs, fns in os.walk(path):
for root, dirs, fns in walk(path):
for fn in fns:
if (fnmatch.fnmatch(fn, "*.trash") or
fnmatch.fnmatch(fn, "*" + CONDA_TEMP_EXTENSION)):
file_path = os.path.join(root, fn)
fnmatch.fnmatch(fn, "*" + CONDA_TEMP_EXTENSION)):
file_path = join(root, fn)
try:
os.unlink(file_path)
unlink(file_path)
except EnvironmentError:
log.warn("File at {} could not be cleaned up. It's probably still in-use.".format(file_path))
log.warn("File at {} could not be cleaned up. "
"It's probably still in-use.".format(file_path))

def _execute(args, parser):
json_result = {
Expand Down Expand Up @@ -269,10 +272,10 @@ def _execute(args, parser):
one_target_ran = True

if args.all:
clean_tempfiles(sys.prefix)
clean_tmp_files(sys.prefix)
elif args.tempfiles:
for path in args.tempfiles:
clean_tempfiles(path)
clean_tmp_files(path)

if not one_target_ran:
from ..exceptions import ArgumentError
Expand Down
2 changes: 1 addition & 1 deletion conda/cli/main_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..base.context import context
from ..common.path import paths_equal
from ..exceptions import CondaValueError
from ..gateways.disk.delete import delete_trash, rm_rf
from ..gateways.disk.delete import rm_rf
from ..gateways.disk.test import is_conda_environment

log = getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion conda/cli/main_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_user_site(): # pragma: no cover
try:
if not on_win:
if exists(expanduser('~/.local/lib')):
python_re = re.compile('python\d\.\d')
python_re = re.compile(r'python\d\.\d')
for path in os.listdir(expanduser('~/.local/lib/')):
if python_re.match(path):
site_dirs.append("~/.local/lib/%s" % path)
Expand Down
4 changes: 1 addition & 3 deletions conda/cli/main_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
from os.path import isdir
import sys

from .common import check_non_admin, specs_from_args
Expand All @@ -15,8 +14,7 @@
from ..core.prefix_data import PrefixData
from ..core.solve import Solver
from ..exceptions import CondaEnvironmentError, CondaValueError
from ..gateways.disk.delete import delete_trash, rm_rf, path_is_clean
from ..gateways.disk.test import is_conda_environment
from ..gateways.disk.delete import rm_rf, path_is_clean
from ..models.match_spec import MatchSpec

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion conda/cli/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run_command(command, *arguments, **kwargs):
with ExitStack() as context_stack:
try:
context_stack.enter_context(argv(['python_api'] + split_command_line))
if kwargs.get("no_capture") != True:
if kwargs.get("no_capture") is not True:
c = context_stack.enter_context(captured(stdout, stderr))
if use_exception_handler:
return_code = conda_exception_handler(do_call, args, p)
Expand Down
2 changes: 1 addition & 1 deletion conda/core/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def run_script(prefix, prec, action='post-link', env_prefix=None):
log.debug("for %s at %s, executing script: $ %s",
prec.dist_str(), env['PREFIX'], ' '.join(command_args))
subprocess_call(command_args, env=env, path=dirname(path))
except CalledProcessError as e: # pragma: no cover
except CalledProcessError:
m = messages(prefix)
if action in ('pre-link', 'post-link'):
if 'openssl' in prec.dist_str():
Expand Down
1 change: 0 additions & 1 deletion conda/core/path_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
'hold_path',
)


@with_metaclass(ABCMeta)
class PathAction(object):

Expand Down
4 changes: 2 additions & 2 deletions conda/core/subdir_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

REPODATA_PICKLE_VERSION = 28
MAX_REPODATA_VERSION = 1
REPODATA_HEADER_RE = b'"(_etag|_mod|_cache_control)":[ ]?"(.*?[^\\\\])"[,\}\s]'
REPODATA_HEADER_RE = rb'"(_etag|_mod|_cache_control)":[ ]?"(.*?[^\\\\])"[,\}\s]'


class SubdirDataType(type):
Expand Down Expand Up @@ -284,7 +284,7 @@ def _read_pickled(self, etag, mod_stamp):
log.debug("found pickle file %s", self.cache_path_pickle)
with open(self.cache_path_pickle, 'rb') as fh:
_pickled_state = pickle.load(fh)
except Exception as e:
except Exception:
log.debug("Failed to load pickled repodata.", exc_info=True)
rm_rf(self.cache_path_pickle)
return None
Expand Down
2 changes: 1 addition & 1 deletion conda/gateways/disk/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(%(func)s())
""")
""") # NOQA

application_entry_point_template = dals("""
# -*- coding: utf-8 -*-
Expand Down
1 change: 0 additions & 1 deletion conda/gateways/disk/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ...base.context import context
from ...common.compat import on_win
from ...common.constants import CONDA_TEMP_EXTENSION
from ...base.context import context


log = getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions conda/gateways/disk/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _patch_path(path):
\\?\ in order to work with API calls.
See http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx for
details.
"""
""" # NOQA
if path.startswith('\\\\?\\'):
return path
path = abspath(path)
Expand Down Expand Up @@ -242,7 +242,7 @@ def is_symlink(path):
path = _patch_path(path)
try:
return _is_symlink(next(find_files(path)))
except WindowsError as orig_error:
except WindowsError as orig_error: # NOQA
tmpl = "Error accessing {path}: {orig_error.message}"
raise builtins.WindowsError(local_format(tmpl))

Expand All @@ -257,7 +257,7 @@ def find_files(spec):
>>> # This test might fail on a non-standard installation
>>> 'Windows' in (fd.filename for fd in root_files)
True
"""
""" # NOQA
fd = WIN32_FIND_DATA()
handle = FindFirstFile(spec, byref(fd))
while True:
Expand Down
3 changes: 2 additions & 1 deletion conda/gateways/disk/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def rename(source_path, destination_path, force=False):
rename_script = join(condabin_dir, 'rename_tmp.bat')
_dirname, _src_fn = split(source_path)
_dest_fn = basename(destination_path)
p = Popen(['cmd.exe', '/C', rename_script, _dirname, _src_fn, _dest_fn], stdout=PIPE, stderr=PIPE)
p = Popen(['cmd.exe', '/C', rename_script, _dirname,
_src_fn, _dest_fn], stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
elif e.errno in (EINVAL, EXDEV):
# https://github.com/conda/conda/issues/6811
Expand Down
4 changes: 2 additions & 2 deletions conda/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def v_fkey_(prec):
filter[prec] = True
try:
depends = self.ms_depends(prec)
except InvalidSpec as e:
except InvalidSpec:
val = filter[prec] = False
else:
val = filter[prec] = all(v_ms_(ms) for ms in depends)
Expand All @@ -155,7 +155,7 @@ def is_valid_prec(prec):
filter_out[prec] = False
try:
has_valid_deps = all(is_valid_spec(ms) for ms in self.ms_depends(prec))
except InvalidSpec as e:
except InvalidSpec:
val = filter_out[prec] = "invalid dep specs"
else:
val = filter_out[prec] = False if has_valid_deps else "invalid depends specs"
Expand Down
2 changes: 1 addition & 1 deletion conda_env/cli/main_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from conda._vendor.auxlib.path import expand
from conda.cli import install as cli_install
from conda.cli.conda_argparse import add_parser_json, add_parser_prefix
from conda.gateways.disk.delete import delete_trash, rm_rf
from conda.gateways.disk.delete import rm_rf
from conda.misc import touch_nonadmin
from .common import get_prefix
from .. import exceptions, specs
Expand Down
1 change: 0 additions & 1 deletion conda_env/cli/main_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from __future__ import absolute_import, print_function

from argparse import Namespace, RawDescriptionHelpFormatter
from os.path import isdir

from conda.cli.conda_argparse import add_output_and_prompt_options, add_parser_prefix

Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ markers =
[pycodestyle]
max-line-length = 99
ignore = E126,E133,E226,E241,E242,E302,E704,E731,E722,W503
exclude = build/*,.tox/*,env/*,test_data/*,tests/*,ve/*,utils/*,*/_vendor/*,conda/compat.py,conda/common/compat.py,conda_env/compat.py
exclude = build/*,.tox/*,devenv*/*,env/*,test_data/*,tests/*,ve/*,utils/*,*/_vendor/*,conda/compat.py,conda/common/compat.py,conda_env/compat.py


[flake8]
max-line-length = 99
ignore = E126,E133,E226,E241,E242,E302,E704,E731,E722,W503,E402
exclude = .asv*,build/*,.tox/*,devenv/*,env/*,test_data/*,tests/*,ve/*,utils/*,*/_vendor/*,conda/compat.py,conda/common/compat.py,conda_env/compat.py
ignore = E126,E133,E226,E241,E242,E302,E704,E731,E722,W503,E402,W504
exclude = .asv*,build/*,.tox/*,devenv*/*,env/*,test_data/*,tests/*,ve/*,utils/*,*/_vendor/*,conda/compat.py,conda/common/compat.py,conda_env/compat.py


[coverage:report]
Expand Down

0 comments on commit c722b8e

Please sign in to comment.