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 linter #25

Merged
merged 1 commit into from
Jul 23, 2023
Merged
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
12 changes: 9 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[flake8]
; ignoring the checks:
; E402 (module level import not at top of file) to set warning filtering before importing modules
ignore = E402
; Disabling the checks that conflict with "black":
; E122 "continuation line missing indentation or outdented"
; E126 "continuation line over-indented for hanging indent"
; E131 "continuation line unaligned for hanging indent"
; E203 "whitespace before ':'"
; E501 "line too long (129 > 120 characters)"
; W503 "line break before binary operator"
select = E,F,W,C,S
ignore = E122,E126,E131,E203,E501,W503
8 changes: 6 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ jobs:
- uses: actions/setup-python@v4
with: { python-version: "3.11", cache: pip }
- run: pip install .[test]
- {name: "lint: black", run: black --check --diff . }
- {name: "lint: isort", run: isort --check --diff . }
- name: "lint: isort"
run: make isort
- name: "lint: black"
run: make black
- name: "lint: flake8"
run: make flake8
# Temporarily disabled due to bugs in typing in click library
# https://github.com/pallets/click/pull/2559
# https://github.com/python/mypy/issues/13250
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,37 @@ clean:
rm -rf debian/files debian/.debhelper
rm -rf debian/ch-tools*


.PHONY: lint
lint: isort black flake8

.PHONY: isort
isort:
isort --check --diff .

.PHONY: black
black:
black --check --diff .

.PHONY: flake8
flake8:
flake8 src tests

.PHONY: format
format:
isort .
black .


.PHONY: help
help:
@echo "Base targets:"
@echo " lint Run linters. Alias for \"isort black flake8\"."
@echo " isort Perform isort checks."
@echo " black Perform black checks."
@echo " flake8 Perform flake8 checks."
@echo " format Re-format source code to conform style settings enforced by"
@echo " isort and black tools."
@echo " prepare-changelog Add an autobuild version entity to changelog"
@echo " prepare-version Update version based on latest commit"
@echo " build-python-package Build 'ch-tools' Python package"
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ flit build --no-use-vcs
flit install

# lint
black .
isort .
make lint

# unit tests
pytest
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ test = [
"flit",
"black",
"isort",
"flake8",
"flake8-string-format",
"flake8-print",
"mypy",
"types-pyyaml",
"types-requests",
Expand Down
3 changes: 1 addition & 2 deletions src/ch_tools/chadmin/cli/chs3_backup_group.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
from typing import List

import requests
from click import ClickException, Context, argument, group, option, pass_context
from click import ClickException, argument, group, option, pass_context

from ch_tools.chadmin.internal.backup import unfreeze_backup, unfreeze_table
from ch_tools.chadmin.internal.system import match_ch_version
Expand Down
4 changes: 2 additions & 2 deletions src/ch_tools/chadmin/cli/object_storage_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import sys
from datetime import datetime, timedelta, timezone
from gzip import GzipFile
from io import IOBase, TextIOWrapper
from io import TextIOWrapper
from pathlib import Path
from typing import Dict, Iterator, List, Optional, Union
from typing import Dict, List, Optional

import click
from click import Context, group, option, pass_context
Expand Down
2 changes: 1 addition & 1 deletion src/ch_tools/common/cli/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import humanfriendly
from click import style
from cloup import Color, Context
from cloup import Color
from deepdiff.helper import notpresent
from pygments import highlight
from pygments.formatters.terminal256 import Terminal256Formatter
Expand Down