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

style: apply updated style configs from template #141

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
style: add flake8/other style configs from template
  • Loading branch information
jsstevenson committed Mar 28, 2024
commit 06355c171b6b63ba4fa73b9afb645122fea6dda6
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
ignore = E129,E133,E203,E221,E241,E251,E303,E266,H106,H904,W291
max-line-length = 100
max-complexity = 15
hang-closing = true
exclude =
.eggs
.tox
build
dist
docs/conf.py
tests/*
**/_data/migrations/*
74 changes: 37 additions & 37 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ on:
push:

jobs:
# cqa:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# cache: pip
# cache-dependency-path: '**/setup.cfg'

# - name: Install test dependencies
# run: |
# python -m pip install --upgrade pip
# pip install --use-deprecated=legacy-resolver -e .[dev]

# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

# - name: Format check with isort
# run: |
# isort --check src

# - name: Format check with black
# run: |
# black --check src

# - name: Security check with bandit
# run: |
# bandit -ll -r src
cqa:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: '**/setup.cfg'

- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install --use-deprecated=legacy-resolver -e .[dev]

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Format check with isort
run: |
isort --check src

- name: Format check with black
run: |
black --check src

- name: Security check with bandit
run: |
bandit -ll -r src

test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Test with pytest
run: |
make test

deploy:
needs:
# - cqa
Expand Down
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: local
hooks:
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
- id: pyright
name: pyright
entry: pyright
language: system
types: [python]
- id: isort
name: isort
entry: isort
language: system
types: [python]
- id: black
name: black
entry: black
language: system
types: [python]
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.SUFFIXES:


SHELL:=bash -e -o pipefail -O globstar
SHELL:=bash -e -o pipefail # -O globstar

SELF:=$(firstword $(MAKEFILE_LIST))

Expand Down Expand Up @@ -47,6 +47,7 @@ ${VE_DIR}:
.PHONY: develop
develop:
pip install -e .[dev]
pre-commit install

#=> install: install package
.PHONY: install
Expand Down Expand Up @@ -91,6 +92,18 @@ test-%:
tox:
tox

#=> cqa: execute code quality tests
cqa:
flake8 src --show-source --statistics
pyright
isort --check src --profile black
black --check src
bandit -ll -r src

#=> reformat: reformat code
.PHONY: reformat
reformat:
pre-commit

############################################################################
#= UTILITY TARGETS
Expand Down Expand Up @@ -144,13 +157,13 @@ distclean: cleanest

## <LICENSE>
## 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.
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ tested. Patches to get other systems working would be welcomed.
$ pip install seqrepo
$ sudo mkdir -p /usr/local/share/seqrepo
$ sudo chown $USER /usr/local/share/seqrepo
$ seqrepo pull -i 2018-11-26
$ seqrepo show-status -i 2018-11-26
$ seqrepo pull -i 2018-11-26
$ seqrepo show-status -i 2018-11-26
seqrepo 0.2.3.post3.dev8+nb8298bd62283
root directory: /usr/local/share/seqrepo/2018-11-26, 7.9 GB
backends: fastadir (schema 1), seqaliasdb (schema 1)
backends: fastadir (schema 1), seqaliasdb (schema 1)
sequences: 773587 sequences, 93051609959 residues, 192 files
aliases: 5579572 aliases, 5480085 current, 26 namespaces, 773587 sequences

Expand Down Expand Up @@ -187,6 +187,15 @@ Here's how to get started developing:
source venv/bin/activate
seqrepo --version

Code reformatting:

make reformat

Install pre-commit hook:

# included in `make devready`, not necessary for new installations
pre-commit install

## Building a docker image

Docker images are available at https://hub.docker.com/r/biocommons/seqrepo.
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ line-length = 100
profile = "black"
src_paths = ["src", "tests"]

# [tool.flake8]
# flake8 does not support configuration in pyproject.toml
# https://github.com/PyCQA/flake8/issues/234#issuecomment-812800832
# The config in setup.cfg

[tool.pyright]
include = ["src", "tests"]

Expand Down