From b7f8669e8522a17d341cd87217e9abd1038a7f5f Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 5 Jun 2024 09:38:36 -0400 Subject: [PATCH] style: format with Ruff --- .github/workflows/python-package.yml | 4 ++-- Makefile | 12 ++++++------ pyproject.toml | 8 +++++--- setup.cfg | 4 ++-- src/bioutils/accessions.py | 1 + src/bioutils/normalize.py | 4 +--- src/bioutils/seqfetcher.py | 3 +-- src/bioutils/sequences.py | 3 +-- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1816684..197b6f1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -34,9 +34,9 @@ jobs: run: | isort --check src - - name: Format check with black + - name: Format check with Ruff run: | - black --check src + ruff format --check src # Disable bandit until issues are resolved # - name: Security check with bandit diff --git a/Makefile b/Makefile index 86ea9df..e95df5f 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ build: %: cqa: flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics isort --profile black --check src - black --check src + ruff format --check src bandit -ll -r src #=> test: execute tests @@ -95,9 +95,9 @@ tox: .PHONY: reformat reformat: @if ! git diff --cached --exit-code >/dev/null; then echo "Repository not clean" 1>&2; exit 1; fi - black src tests + ruff format src tests isort src tests - git commit -a -m "reformatted with black and isort" + git commit -a -m "reformatted with ruff and isort" #=> rename: rename files and substitute content for new repo name .PHONY: rename @@ -141,13 +141,13 @@ distclean: cleanest ## ## Copyright 2023 Source Code Committers -## +## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. ## You may obtain a copy of the License at -## +## ## http://www.apache.org/licenses/LICENSE-2.0 -## +## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pyproject.toml b/pyproject.toml index 4de0b0a..17c2bbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,9 +90,6 @@ exclude_lines = [ "if __name__ == .__main__.:", ] -[tool.black] -line-length = 120 - [tool.isort] profile = "black" @@ -107,3 +104,8 @@ disable = "R0913" [tool.pylint.format] max-line-length = "120" + + +[tool.ruff] +src = ["src", "test"] +line-length = 120 diff --git a/setup.cfg b/setup.cfg index b6ecf23..40cc960 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,20 +15,20 @@ zip_safe = True [options.extras_require] dev = bandit~=1.7 - black~=22.3 build~=0.8 flake8~=4.0 ipython~=8.4 isort~=5.10 mypy pylint~=2.14 + ruff == 0.4.4 test = pytest~=7.1 pytest-cov~=4.0 pytest-optional-tests tox~=3.25 vcrpy -docs = +docs = mkdocs [options.packages.find] diff --git a/src/bioutils/accessions.py b/src/bioutils/accessions.py index 52c0ab1..7a36e1b 100644 --- a/src/bioutils/accessions.py +++ b/src/bioutils/accessions.py @@ -25,6 +25,7 @@ The string form may be used as a CURIE, in which case the document in which the CURIE is used must contain a map of ``{namespace : uri}``. """ + import re from .exceptions import BioutilsError diff --git a/src/bioutils/normalize.py b/src/bioutils/normalize.py index 7e33c20..2e9cff6 100644 --- a/src/bioutils/normalize.py +++ b/src/bioutils/normalize.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -"""Provides functionality for normalizing alleles, ensuring comparable representations. - -""" +"""Provides functionality for normalizing alleles, ensuring comparable representations.""" import copy import enum diff --git a/src/bioutils/seqfetcher.py b/src/bioutils/seqfetcher.py index a94e294..d0455e2 100644 --- a/src/bioutils/seqfetcher.py +++ b/src/bioutils/seqfetcher.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -"""Provides sequence fetching from NCBI and Ensembl. +"""Provides sequence fetching from NCBI and Ensembl.""" -""" import logging import os import random diff --git a/src/bioutils/sequences.py b/src/bioutils/sequences.py index e994cea..da948a4 100644 --- a/src/bioutils/sequences.py +++ b/src/bioutils/sequences.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -"""Simple functions and lookup tables for nucleic acid and amino acid sequences. -""" +"""Simple functions and lookup tables for nucleic acid and amino acid sequences.""" import logging import re