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

Flake8 #1050

Merged
merged 9 commits into from
Mar 31, 2021
Merged

Flake8 #1050

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
run: |
git add --all
git commit \
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git push origin master \
|| echo "Nothing new to commit"
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git push origin master \
|| echo "Nothing new to commit"
working-directory: src
51 changes: 51 additions & 0 deletions .github/workflows/flake8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: flake8
on:
pull_request:
paths-ignore:
- '.github/docker/**'
- '.github/workflows/windows-docker-image.yaml'
- 'src/rez/utils/_version.py'
- 'wiki/**'
- 'metrics/**'
- 'data/**'
- '**.md'
push:
paths-ignore:
- '.github/docker/**'
- '.github/workflows/windows-docker-image.yaml'
- 'src/rez/utils/_version.py'
- 'wiki/**'
- 'metrics/**'
- 'data/**'
- '**.md'

jobs:
lint:
name: Run Linter
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install Dependencies
run: |
pip install flake8

- name: Run flake8
run: >-
find -name '*.py'
-not -path './build_utils/*'
-not -path './rez/vendor/*'
-not -path './rez/data/*'
-not -path './support/*'
-not -path './rez/backport/*'
-not -path './rezgui/*'
| xargs flake8 --ignore
E241,E265,E266,E741,E742,E722,F821,W503
working-directory: src
6 changes: 3 additions & 3 deletions .github/workflows/sphinx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ jobs:
run: |
git add .
git commit \
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git push --force origin gh-pages \
|| echo "Nothing new to commit"
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git push --force origin gh-pages \
|| echo "Nothing new to commit"
8 changes: 4 additions & 4 deletions .github/workflows/wiki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Git commit and push
run: |
git commit \
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git remote set-url origin "${{ env.CLONE_URL }}" \
&& git push origin master \
|| echo "Nothing new to commit"
-m "Generated from GitHub "${{ github.workflow }}" Workflow" \
&& git remote set-url origin "${{ env.CLONE_URL }}" \
&& git push origin master \
|| echo "Nothing new to commit"
6 changes: 3 additions & 3 deletions src/rez/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import print_function

from rez.utils._version import _rez_version
import atexit
import sys
import os

Expand All @@ -11,7 +10,7 @@
__license__ = "LGPL"


module_root_path = __path__[0]
module_root_path = __path__[0] # noqa


# TODO: Revamp logging. For now, this is here for backwards compatibility
Expand Down Expand Up @@ -43,7 +42,8 @@ def _init_logging():
# actions registered on SIGUSR1
action = os.getenv("REZ_SIGUSR1_ACTION")
if action:
import signal, traceback
import signal
import traceback

if action == "print_stack":
def callback(sig, frame):
Expand Down
1 change: 0 additions & 1 deletion src/rez/bind/_pymodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from rez.exceptions import RezBindError
from rez.system import system
from rez.utils.logging_ import print_warning
import subprocess
import shutil
import sys
import os.path
Expand Down
6 changes: 4 additions & 2 deletions src/rez/bind/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def bind(path, version_range=None, opts=None, parser=None):

with make_package("os", path) as pkg:
pkg.version = version
pkg.requires = ["platform-%s" % system.platform,
"arch-%s" % system.arch]
pkg.requires = [
"platform-%s" % system.platform,
"arch-%s" % system.arch
]

return pkg.installed_variants

Expand Down
6 changes: 3 additions & 3 deletions src/rez/bind/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from rez.system import system
from rez.utils.lint_helper import env
from rez.utils.platform_ import platform_
from rez.vendor.version.version import Version
import shutil
import os.path

Expand All @@ -26,9 +25,10 @@ def commands():
def post_commands():
# these are the builtin modules for this python executable. If we don't
# include these, some python behavior can be incorrect.
import os, os.path
import os
import os.path

path = os.path.join(this.root, "python")
path = os.path.join(this.root, "python") # noqa
for dirname in os.listdir(path):
path_ = os.path.join(path, dirname)
env.PYTHONPATH.append(path_)
Expand Down
2 changes: 1 addition & 1 deletion src/rez/build_process_.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings
from rez.build_process import *
from rez.build_process import * # noqa


warnings.warn(
Expand Down
10 changes: 6 additions & 4 deletions src/rez/cli/_complete_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, parser, comp_line, comp_point):
self.exclude = None
self.validator = default_validator
self.wordbreaks = " \t\"'@><=;|&(:" # TODO: might need to be configurable/OS specific

if USING_PYTHON2:
comp_line = comp_line.decode(sys_encoding)
comp_point = len(comp_line[:comp_point].decode(sys_encoding))
Expand All @@ -22,9 +22,11 @@ def __init__(self, parser, comp_line, comp_point):
cword_prequote, cword_prefix, cword_suffix, comp_words, \
first_colon_pos = split_line(comp_line, comp_point)

debug("\nLINE: '{l}'\nPREQUOTE: '{pq}'\nPREFIX: '{p}'".format(l=comp_line, pq=cword_prequote, p=cword_prefix),
"\nSUFFIX: '{s}'".format(s=cword_suffix),
"\nWORDS:", comp_words)
debug(
"\nLINE: '{l}'\nPREQUOTE: '{pq}'\nPREFIX: '{p}'".format(l=comp_line, pq=cword_prequote, p=cword_prefix),
"\nSUFFIX: '{s}'".format(s=cword_suffix),
"\nWORDS:", comp_words
)

completions = self._get_completions(comp_words, cword_prefix,
cword_prequote, first_colon_pos)
Expand Down
2 changes: 1 addition & 1 deletion src/rez/cli/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def run_cmd():
else:
try:
returncode = run_cmd()
except (NotImplementedError, RezSystemError) as e:
except (NotImplementedError, RezSystemError):
raise
except exc_type as e:
print_error("%s: %s" % (e.__class__.__name__, str(e)))
Expand Down
2 changes: 1 addition & 1 deletion src/rez/cli/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _pop_arg(l, p):

# replace '--' with special '--N#' flag so that subcommands can specify
# custom completions.
regex = re.compile("\s--\s")
regex = re.compile(r"\s--\s")
ddashes = regex.findall(comp_line)
for i, ddash in enumerate(ddashes):
j = comp_line.find(ddash)
Expand Down
7 changes: 4 additions & 3 deletions src/rez/cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
# disable them in this tool.
#
import os
import json
import sys

os.environ.update({
"REZ_CONTEXT_TRACKING_HOST": '',
"REZ_WRITE_PACKAGE_CACHE": "False"
})

import json
import sys
from rez.rex import OutputStyle
from rez.rex import OutputStyle # noqa


def setup_parser(parser, completions=False):
Expand Down
3 changes: 1 addition & 2 deletions src/rez/cli/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def setup_parser(parser, completions=False):
help="select variants to copy (zero-indexed).")
parser.add_argument(
"--variant-uri", metavar="URI",
help="copy variant with the given URI. Ignores --variants."
)
help="copy variant with the given URI. Ignores --variants.")
pkg_action = parser.add_argument(
"PKG", nargs='?',
help="package to copy")
Expand Down
4 changes: 2 additions & 2 deletions src/rez/cli/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def setup_parser(parser, completions=False):
help="install as released package; if not set, package is installed "
"locally only")
parser.add_argument(
"-p", "--prefix", type=str, metavar='PATH',
help="install to a custom package repository path.")
"-p", "--prefix", type=str, metavar='PATH',
help="install to a custom package repository path.")
parser.add_argument(
"PACKAGE",
help="package to install or archive/url to install from")
Expand Down
1 change: 1 addition & 0 deletions src/rez/cli/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

all_module_tests = []


def setup_parser(parser, completions=False):
parser.add_argument(
"tests", metavar="NAMED_TEST", default=[], nargs="*",
Expand Down
4 changes: 2 additions & 2 deletions src/rez/cli/yaml2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@


def setup_parser(parser, completions=False):
PKG_action = parser.add_argument(
parser.add_argument(
"PATH", type=str, nargs='?',
help="path to yaml to convert, or directory to search for package.yaml;"
" cwd if not provided")
" cwd if not provided")


def command(opts, parser, extra_arg_groups=None):
Expand Down
20 changes: 14 additions & 6 deletions src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def _parse_env_var(self, value):
value = value.replace(self.sep, ' ').split()
return [x for x in value if x]


class PipInstallRemaps(Setting):
"""Ordered, pip install remappings."""
PARDIR, SEP = map(re.escape, (os.pardir, os.sep))
Expand All @@ -143,6 +144,7 @@ def validate(self, data):
for remap in super(PipInstallRemaps, self).validate(data)
]


class OptionalStrList(StrList):
schema = Or(And(None, Use(lambda x: [])),
[basestring])
Expand Down Expand Up @@ -556,13 +558,17 @@ def remove_override(self, key):

def warn(self, key):
"""Returns True if the warning setting is enabled."""
return (not self.quiet and not self.warn_none and
(self.warn_all or getattr(self, "warn_%s" % key)))
return (
not self.quiet and not self.warn_none
and (self.warn_all or getattr(self, "warn_%s" % key))
)

def debug(self, key):
"""Returns True if the debug setting is enabled."""
return (not self.quiet and not self.debug_none and
(self.debug_all or getattr(self, "debug_%s" % key)))
return (
not self.quiet and not self.debug_none
and (self.debug_all or getattr(self, "debug_%s" % key))
)

def debug_printer(self, key):
"""Returns a printer object suitably enabled based on the given key."""
Expand Down Expand Up @@ -633,8 +639,10 @@ def _get_plugin_completions(prefix_):
return _get_plugin_completions(prefix_)
return []
else:
keys = ([x for x in self._schema_keys if isinstance(x, basestring)]
+ ["plugins"])
keys = (
[x for x in self._schema_keys if isinstance(x, basestring)]
+ ["plugins"]
)
keys = [x for x in keys if x.startswith(prefix)]
if keys == ["plugins"]:
keys += _get_plugin_completions('')
Expand Down
2 changes: 0 additions & 2 deletions src/rez/developer_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ def _get_preprocessed(self, data):
from rez.utils.data_utils import get_dict_diff_str
from copy import deepcopy

package_preprocess_mode = self.config.package_preprocess_mode

def _get_package_level():
return getattr(self, "preprocess", None)

Expand Down
3 changes: 0 additions & 3 deletions src/rez/package_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import argparse
import os.path
import os
import sys


def get_bind_modules(verbose=False):
Expand Down Expand Up @@ -95,7 +94,6 @@ def bind_package(name, path=None, version_range=None, no_deps=False,
pending = set([name])
installed_variants = []
installed_package_names = set()
primary = True

# bind package and possibly dependencies
while pending:
Expand Down Expand Up @@ -130,7 +128,6 @@ def bind_package(name, path=None, version_range=None, no_deps=False,
pending.add(requirement.name)

# non-primary packages are treated a little differently
primary = False
version_range = None
bind_args = None
exc_type = RezBindError
Expand Down
9 changes: 5 additions & 4 deletions src/rez/package_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def add_variant(self, variant, force=False):
# support device identification.
#
dev_stat_not_supported = (
platform.system() == "Windows" and
sys.version_info[:2] < (3, 4)
platform.system() == "Windows"
and sys.version_info[:2] < (3, 4)
)

if not config.package_cache_same_device and not dev_stat_not_supported:
Expand Down Expand Up @@ -276,6 +276,7 @@ def add_variant(self, variant, force=False):
# copies, and report them as VARIANT_COPY_STALLED status.
#
still_copying = True

def _while_copying():
while still_copying:
time.sleep(self._COPYING_TIME_INC)
Expand Down Expand Up @@ -611,8 +612,8 @@ def clean(self, time_limit=None):

def should_exit():
return (
time_limit is not None and
(time.time() - now) > time_limit
time_limit is not None
and (time.time() - now) > time_limit
)

# find variants to delete
Expand Down
Loading