Skip to content
Snippets Groups Projects
Commit 269199ad authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[flake8] ignore E203 as that is incompatible with black

parent 1269f567
No related branches found
No related tags found
No related merge requests found
Pipeline #52940 failed
[flake8]
max-line-length = 88
select = B,C,E,F,W,T4,B9,B950
ignore = E501, W503, E203
max-line-length = 80
ignore = E501,W503,E302,E402,E203
......@@ -37,6 +37,8 @@ build_linux:
- python3 ./bob/devtools/bootstrap.py -vv build
- source ${CONDA_ROOT}/etc/profile.d/conda.sh
- conda activate base
- pip install pre-commit
- pre-commit run --all-files --show-diff-on-failure
- python3 ./bob/devtools/build.py -vv --twine-check
artifacts:
paths:
......@@ -59,6 +61,8 @@ build_macos_intel:
- python3 ./bob/devtools/bootstrap.py -vv build
- source ${CONDA_ROOT}/etc/profile.d/conda.sh
- conda activate base
- pip install pre-commit
- pre-commit run --all-files --show-diff-on-failure
- python3 ./bob/devtools/build.py -vv
artifacts:
paths:
......
......@@ -255,7 +255,9 @@ def readme(package):
failed = check([k])
if failed:
raise RuntimeError("twine check (a.k.a. readme check) %s: FAILED" % k)
raise RuntimeError(
"twine check (a.k.a. readme check) %s: FAILED" % k
)
else:
logger.info("twine check (a.k.a. readme check) %s: OK", k)
......@@ -395,7 +397,9 @@ def base_build(order, group, dry_run):
condarc_options = yaml.load(BASE_CONDARC, Loader=yaml.FullLoader)
# dump packages at conda_root
condarc_options["croot"] = os.path.join(os.environ["CONDA_ROOT"], "conda-bld")
condarc_options["croot"] = os.path.join(
os.environ["CONDA_ROOT"], "conda-bld"
)
recipes = load_order_file(order)
......@@ -493,7 +497,8 @@ def test(ctx, dry_run):
ctx.invoke(
test,
package=glob.glob(base_path + "*.conda") + glob.glob(base_path + "*.tar.bz2"),
package=glob.glob(base_path + "*.conda")
+ glob.glob(base_path + "*.tar.bz2"),
condarc=condarc,
config=variants_file,
append_file=append_file,
......@@ -673,12 +678,16 @@ def nightlies(ctx, order, dry_run):
for n, (package, branch) in enumerate(packages):
echo_normal("\n" + (80 * "="))
echo_normal("Building %s@%s (%d/%d)" % (package, branch, n + 1, len(packages)))
echo_normal(
"Building %s@%s (%d/%d)" % (package, branch, n + 1, len(packages))
)
echo_normal((80 * "=") + "\n")
group, name = package.split("/", 1)
clone_to = os.path.join(os.environ["CI_PROJECT_DIR"], "src", group, name)
clone_to = os.path.join(
os.environ["CI_PROJECT_DIR"], "src", group, name
)
dirname = os.path.dirname(clone_to)
if not os.path.exists(dirname):
os.makedirs(dirname)
......@@ -767,7 +776,8 @@ def nightlies(ctx, order, dry_run):
local_docs = os.path.join(os.environ["CI_PROJECT_DIR"], "sphinx")
if os.path.exists(local_docs):
logger.debug(
"Sphinx output was generated during test/rebuild " "of %s - Erasing...",
"Sphinx output was generated during test/rebuild "
"of %s - Erasing...",
package,
)
shutil.rmtree(local_docs)
......@@ -869,7 +879,8 @@ def docs(ctx, requirement, dry_run):
clone_to,
)
git.Repo.clone_from(
"https://gitlab-ci-token:%s@gitlab.idiap.ch/%s" % (token, package),
"https://gitlab-ci-token:%s@gitlab.idiap.ch/%s"
% (token, package),
clone_to,
branch=branch,
depth=1,
......@@ -895,7 +906,9 @@ def docs(ctx, requirement, dry_run):
with open(requirements_path) as f:
extra_intersphinx += comment_cleanup(f.readlines())
nitpick_path = os.path.join(clone_to, "doc", "nitpick-exceptions.txt")
nitpick_path = os.path.join(
clone_to, "doc", "nitpick-exceptions.txt"
)
if os.path.exists(nitpick_path):
with open(nitpick_path) as f:
nitpick += comment_cleanup(f.readlines())
......@@ -994,26 +1007,20 @@ Example:
bdt ci check -vv
"""
)
@click.option(
"-d",
"--dir",
"root",
default=os.path.realpath(os.curdir),
help="Path to the root folder of the package.",
)
@verbosity_option()
@bdt.raise_on_error
def check(root):
def check():
# checks if a pyproject.toml file exists
path = os.path.join(root, "pyproject.toml")
path = "pyproject.toml"
if not os.path.isfile(path):
raise RuntimeError(
"pyproject.toml file not found at the root folder of the package. "
"See https://gitlab.idiap.ch/bob/bob/-/wikis/ci-checks#pyprojecttoml"
f"{path} file not found at the root folder of the package."
f"See https://gitlab.idiap.ch/bob/bob/-/wikis/ci-checks#"
f"pyprojecttoml"
)
# if there is a pre-commit configuration file, run the tests
path = os.path.join(root, ".pre-commit-config.yaml")
path = ".pre-commit-config.yaml"
if os.path.isfile(path):
from shutil import which
......@@ -1025,9 +1032,16 @@ def check(root):
env = os.environ.copy()
env["SKIP"] = "sphinx-build,sphinx-doctest"
run_cmdline(
[which("pre-commit"), "run", "--all-files", "--show-diff-on-failure"],
[
which("pre-commit"),
"run",
"--all-files",
"--show-diff-on-failure",
],
env=env,
cwd=root,
)
else:
logger.info(f"Cannot find file {path}. Skipping pre-commit checks...")
logger.info(
f"Cannot find file {path} at the root folder of the package. "
f"Skipping pre-commit checks..."
)
......@@ -111,7 +111,11 @@ def new(package, author, email, title, license, output_dir):
# Title
# =======
rst_title = (
("=" * (2 + len(title))) + "\n " + title + "\n" + ("=" * (2 + len(title)))
("=" * (2 + len(title)))
+ "\n "
+ title
+ "\n"
+ ("=" * (2 + len(title)))
)
# the jinja context defines the substitutions to be performed
......@@ -132,7 +136,9 @@ def new(package, author, email, title, license, output_dir):
# copy the whole template structure and de-templatize the needed files
if output_dir is None:
output_dir = os.path.join(os.path.realpath(os.curdir), name)
logger.info("Creating structure for %s at directory %s", package, output_dir)
logger.info(
"Creating structure for %s at directory %s", package, output_dir
)
if os.path.exists(output_dir):
raise IOError(
......@@ -154,7 +160,6 @@ def new(package, author, email, title, license, output_dir):
".flake8",
".gitignore",
".gitlab-ci.yml",
".isort.cfg",
".pre-commit-config.yaml",
"buildout.cfg",
"doc/conf.py",
......@@ -180,7 +185,9 @@ def new(package, author, email, title, license, output_dir):
__name__, os.path.join("..", "templates")
)
logger.info("Creating base %s python module", group)
shutil.copytree(os.path.join(template_dir, "pkg"), os.path.join(output_dir, group))
shutil.copytree(
os.path.join(template_dir, "pkg"), os.path.join(output_dir, group)
)
# copies specific images to the right spot
copy_file(os.path.join("doc", "img", "%s-favicon.ico" % group), output_dir)
......@@ -199,4 +206,6 @@ def new(package, author, email, title, license, output_dir):
comment_start_string="(#",
comment_end_string="#)",
)
render_template(conda_env, os.path.join("conda", "meta.yaml"), context, output_dir)
render_template(
conda_env, os.path.join("conda", "meta.yaml"), context, output_dir
)
[flake8]
max-line-length = 88
select = B,C,E,F,W,T4,B9,B950
ignore = E501, W503, E203
max-line-length = 80
ignore = E501,W503,E302,E402,E203
[settings]
profile=black
order_by_type=true
lines_between_types=1
......@@ -2,20 +2,19 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.8.0
rev: 5.9.3
hooks:
- id: isort
args: [--profile, "black"]
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.7b0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-ast
- id: check-case-conflict
......@@ -23,21 +22,5 @@ repos:
- id: end-of-file-fixer
- id: debug-statements
- id: check-added-large-files
- repo: local
hooks:
- id: sphinx-build
name: sphinx build
entry: python -m sphinx.cmd.build
args: [-a, -E, -W, doc, sphinx]
language: system
files: ^doc/
types: [file]
pass_filenames: false
- id: sphinx-doctest
name: sphinx doctest
entry: python -m sphinx.cmd.build
args: [-a, -E, -b, doctest, doc, sphinx]
language: system
files: ^doc/
types: [file]
pass_filenames: false
- id: check-yaml
exclude: .*/meta.yaml
[build-system]
requires = ["setuptools", "wheel", "bob.extension"]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel", "bob.extension"]
build-backend = "setuptools.build_meta"
[tool.isort]
profile = "black"
line_length = 80
order_by_type = true
lines_between_types = 1
[tool.black]
line-length = 80
......@@ -101,7 +101,6 @@ test:
- bdt ci docs --help
- bdt ci clean-betas --help
- bdt ci check --help
- bdt ci check -vv --dir {{ environ.get('RECIPE_DIR') + '/..' }}
- bdt dav --help
- bdt dav list --help
- bdt dav makedirs --help
......
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.isort]
profile = "black"
line_length = 80
order_by_type = true
lines_between_types = 1
[tool.black]
line-length = 80
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment