diff --git a/.isort.cfg b/.isort.cfg index 27c67f127..d8c44da35 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,2 +1,8 @@ [settings] skip=aqt/forms +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 +ensure_newline_before_comments=true diff --git a/Makefile b/Makefile index 826ad18e2..8a838a4d6 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules RUNARGS := .SUFFIXES: +BLACKARGS := -t py36 anki aqt $(shell mkdir -p .build) @@ -112,7 +113,7 @@ run: build ###################### .PHONY: check -check: mypy pyimports pytest pylint checkpretty +check: mypy pyimports pyfmt pytest pylint checkpretty # Checking python ###################### @@ -132,24 +133,32 @@ PYCHECKDEPS := $(BUILDDEPS) .build/pycheckreqs $(shell find anki aqt -name '*.py touch $@ .build/pyimports: $(PYCHECKDEPS) - isort -rc anki aqt --check # if this fails, run 'make fixpyimports' + isort anki aqt --check # if this fails, run 'make fixpyimports' + touch $@ + +.build/pyfmt: $(PYCHECKDEPS) + black --check $(BLACKARGS) # if this fails, run 'make fixpyfmt' touch $@ .build/pytype: $(PYCHECKDEPS) .build/pytypereqs pytype --config pytype.conf touch $@ -.PHONY: mypy pytest pylint pytype pyimports fixpyimports +.PHONY: mypy pytest pylint pytype pyimports pyfmt mypy: .build/mypy pytest: .build/pytest pylint: .build/pylint pytype: .build/pytype pyimports: .build/pyimports +pyfmt: .build/pyfmt -.PHONY: fixpyimports +.PHONY: fixpyimports fixpyfmt fixpyimports: - isort -rc anki aqt + isort anki aqt + +fixpyfmt: + black $(BLACKARGS) anki aqt # Checking typescript ###################### diff --git a/anki/__init__.py b/anki/__init__.py index 9d705bf52..baea42e12 100644 --- a/anki/__init__.py +++ b/anki/__init__.py @@ -12,5 +12,8 @@ if sys.version_info[0] < 3 or sys.version_info[1] < 5: if sys.getfilesystemencoding().lower() in ("ascii", "ansi_x3.4-1968"): raise Exception("Anki requires a UTF-8 locale.") +# fmt: off version="2.1.17" # build scripts grep this line, so preserve formatting +# fmt: on + __all__ = ["Collection"] diff --git a/aqt/pinnedmodules.py b/aqt/pinnedmodules.py index 40c1ba4e8..6fd734184 100644 --- a/aqt/pinnedmodules.py +++ b/aqt/pinnedmodules.py @@ -9,10 +9,12 @@ # included implicitly in the past, and relied upon by some add-ons import cgi import decimal + # useful for add-ons import logging import logging.config import logging.handlers + # required by requests library import queue import typing diff --git a/requirements.check b/requirements.check index 5faae131e..6131fa459 100644 --- a/requirements.check +++ b/requirements.check @@ -2,4 +2,6 @@ nose mock mypy==0.750 pylint -isort +# fixme: when isort 5.0 is released, switch to pypy +git+https://github.com/dae/isort +black