From f947bd350afabffd81bd5a79adfadf2f83f54a51 Mon Sep 17 00:00:00 2001 From: Bryan Bugyi Date: Mon, 15 Jan 2024 21:03:59 -0500 Subject: [PATCH] Run cruft update --- .cruft.json | 2 +- .gitignore | 6 ++++ .pylintrc | 63 ---------------------------------- CONTRIBUTING.md | 4 +-- README.md | 15 ++++++-- bin/render_all_cogs | 13 +++++-- docs/design/design.md | 0 docs/design/design.template.md | 0 lib/bugyi.sh | 2 +- pyproject.toml | 2 +- requirements-dev.in | 4 +-- setup.cfg | 4 ++- targets.mk | 17 ++++++--- 13 files changed, 53 insertions(+), 79 deletions(-) create mode 100644 docs/design/design.md create mode 100644 docs/design/design.template.md diff --git a/.cruft.json b/.cruft.json index 5bef4a6..59d20e3 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/python-boltons/cc-python", - "commit": "15b51fa172bfc123ee06597c5360fa261619b8df", + "commit": "42af5949086defc1b2f71b2b1354f1b3cfbd029a", "checkout": null, "context": { "cookiecutter": { diff --git a/.gitignore b/.gitignore index 46d0bb7..1251d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,9 @@ venv.bak/ # git conflict files *.rej + +# pyright config file +pyrightconfig.json + +# local sqlite databases +*.db diff --git a/.pylintrc b/.pylintrc index 8d1c765..bc6b2be 100644 --- a/.pylintrc +++ b/.pylintrc @@ -7,9 +7,6 @@ # pygtk.require(). #init-hook= -# Profiled execution. -profile=no - # Add files or directories to the blacklist. They should be base names, not # paths. ignore=CVS @@ -39,14 +36,12 @@ enable=imports # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" disable=design, - bad-continuation, blacklisted-name, broad-except, consider-using-enumerate, consider-using-f-string, consider-using-in, consider-using-with, - deprecated-lambda, global-statement, import-error, import-outside-toplevel, @@ -61,11 +56,9 @@ disable=design, missing-docstring, multiple-statements, no-else-return, - no-init, no-member, no-name-in-module, non-parent-init-called, - old-style-class, protected-access, super-init-not-called, too-many-lines, @@ -83,11 +76,6 @@ disable=design, # mypackage.mymodule.MyReporterClass. output-format=text -# Put messages in a separate file for each module / package specified on the -# command line instead of printing them on stdout. Reports (if any) will be -# written in a file name "pylint_global.[txt|html]". -files-output=no - # Tells whether to display a full report or only the messages reports=no @@ -98,10 +86,6 @@ reports=no # (RP0004). evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) -# Add a comment according to your evaluation note. This is used by the global -# evaluation report (RP0004). -comment=no - # Template used to display messages. This is a python new-style format string # used to format the message information. See doc for all details #msg-template= @@ -124,12 +108,6 @@ ignore-imports=yes [BASIC] -# Required attributes for module, separated by a comma -required-attributes= - -# List of builtins function names that should not be used, separated by a comma -bad-functions=map,filter,apply,input,file - # Good variable names which should always be accepted, separated by a comma good-names=i,j,k,_ @@ -146,63 +124,33 @@ include-naming-hint=no # Regular expression matching correct function names function-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for function names -function-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct variable names variable-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for variable names -variable-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct attribute names attr-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for attribute names -attr-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct argument names argument-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for argument names -argument-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$ -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct method names method-rgx=[a-z_][a-z0-9_]{2,30}$ -# Naming hint for method names -method-name-hint=[a-z_][a-z0-9_]{2,30}$ - # Regular expression which should only match function or class names that do # not require a docstring. no-docstring-rgx=__.*__ @@ -238,9 +186,6 @@ ignore-long-lines=^(.*https?://\S+|.*# type: .*|\s*\S*\s*|[ ]*# TODO.*)$ # else. single-line-if-stmt=no -# List of optional constructs for which whitespace checking is disabled -no-space-check=trailing-comma,dict-separator - # Maximum number of lines in a module max-module-lines=1000 @@ -267,10 +212,6 @@ ignored-modules=twisted.application.internet,quickfix # (useful for classes with attributes dynamically set). ignored-classes=Report,Index,MultiIndex,twisted.internet.reactor,NewOrder,OESControlResponse,OrderReply,FHControlPortResponse,FHControlPortRequest,FHControlPortRequest,FHOperationRequest,GeneratedProtocolMessageType,OrderRequest -# When zope mode is activated, add a predefined set of Zope acquired attributes -# to generated-members. -zope=no - # List of members which are set dynamically and missed by pylint inference # system, and so shouldn't trigger E0201 when accessed. Python regular # expressions are accepted. @@ -326,10 +267,6 @@ max-public-methods=20 [CLASSES] -# List of interface methods to ignore, separated by a comma. This is used for -# instance to not check methods defines in Zope's Interface base class. -ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by - # List of method names used to declare (i.e. assign) instance attributes. defining-attr-methods=__init__,__new__,setUp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d5885ca..ded68e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ If you are proposing a feature: ## Developer's Guide -### 🔢 Basic Usage +### Basic Usage 🔢 Before making a PR please run the following @@ -30,7 +30,7 @@ Before making a PR please run the following * `make lint` to check for any format or convention issues * `make test` to run all tests -### ❓ How do I ...? +### How do I ... ❓
🔧 See available make targets diff --git a/README.md b/README.md index f519bea..be8f4d8 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ _version badges:_ [![Project Version](https://img.shields.io/pypi/v/bolton-logrus)](https://pypi.org/project/bolton-logrus/) [![Python Versions](https://img.shields.io/pypi/pyversions/bolton-logrus)](https://pypi.org/project/bolton-logrus/) -[![Cookiecutter: cc-python](https://img.shields.io/static/v1?label=cc-python&message=2021.12.22&color=d4aa00&logo=cookiecutter&logoColor=d4aa00)](https://github.com/python-boltons/cc-python) +[![Cookiecutter: cc-python](https://img.shields.io/static/v1?label=cc-python&message=2022.01.04&color=d4aa00&logo=cookiecutter&logoColor=d4aa00)](https://github.com/python-boltons/cc-python) [![Docker: pythonboltons/main](https://img.shields.io/static/v1?label=pythonboltons%20%2F%20main&message=2021.12.22&color=8ec4ad&logo=docker&logoColor=8ec4ad)](https://github.com/python-boltons/docker-python) ## Installation 🗹 -To install `bolton-logrus` using [pip][9], run the following +To install `logrus` using [pip][9], run the following commands in your terminal: ``` shell @@ -29,6 +29,17 @@ python3 -m pip install --user bolton-logrus # install logrus If you don't have pip installed, this [Python installation guide][10] can guide you through the process. + + + ## Useful Links 🔗 diff --git a/bin/render_all_cogs b/bin/render_all_cogs index 3a2bf0e..e0ed2d2 100755 --- a/bin/render_all_cogs +++ b/bin/render_all_cogs @@ -14,12 +14,13 @@ # after running this script. ################################################################################# -BIN="$(dirname "$0")" -ROOT="$(dirname "${BIN}")" +readonly BIN="$(dirname "$0")" +readonly ROOT="$(dirname "${BIN}")" source "${ROOT}"/lib/bugyi.sh readonly COG_MARKERS="[[[[[kooky.cog ]]]]] [[[[[end]]]]]" +readonly DESIGN=docs/design COG_TEMPLATE_FILES=( "README.md" ) @@ -36,6 +37,14 @@ function run() { for cog_template_fname in "${COG_TEMPLATE_FILES[@]}"; do if [[ "${check_flag_is_set}" == false ]]; then + # If the mermaid-cli tool is installed... + if command -v mmdc &>/dev/null; then + local md_template="${DESIGN}"/design.template.md + if [[ -f "${md_template}" ]]; then + mmdc -i "${md_template}" -o "${DESIGN}"/design.md + fi + fi + local out_fname="$(mktemp --suffix '.md')" log::info \ diff --git a/docs/design/design.md b/docs/design/design.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/design/design.template.md b/docs/design/design.template.md new file mode 100644 index 0000000..e69de29 diff --git a/lib/bugyi.sh b/lib/bugyi.sh index eb2e5a5..865bc77 100644 --- a/lib/bugyi.sh +++ b/lib/bugyi.sh @@ -144,7 +144,7 @@ function die() { function log::debug() { if [[ "${DEBUG}" = true || "${VERBOSE}" -gt 0 ]]; then _log "debug" "${COLOR_PURPLE}" "$@"; fi; } function log::error() { _log "error" "${COLOR_RED}" "$@"; } function log::info() { _log "info" "${COLOR_GREEN}" "$@"; } -function log::warning() { _log "warning" "${COLOR_YELLOW}" "$@"; } +function log::warn() { _log "warning" "${COLOR_YELLOW}" "$@"; } function _log() { local level="$1" shift diff --git a/pyproject.toml b/pyproject.toml index a07d3bb..10adbbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 79 -experimental-string-processing = true +preview = true [tool.pydocstyle] match = '.*\.py' diff --git a/requirements-dev.in b/requirements-dev.in index e00b721..5b3d18a 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -13,7 +13,7 @@ black cogapp ~= 3.3 flake8 isort -mypy != 0.920, != 0.921, != 0.930 # workaround for https://github.com/samuelcolvin/pydantic/pull/3175 +mypy pydocstyle[toml] pylint @@ -21,7 +21,7 @@ pylint types-freezegun ~= 1.1 ### Docs -m2r2 +m2r2 != 0.3.3 # since this version requires docutils>=0.19 (see https://github.com/CrossNox/m2r2/compare/v0.3.2...v0.3.3) sphinx sphinx-rtd-theme sphinx-autodoc-typehints diff --git a/setup.cfg b/setup.cfg index 5dcf3a7..0a99b16 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,8 @@ exclude_lines = # Don't complain if non-runnable code isn't run: if 0: if __name__ == .__main__.: + [ ]*pass[ ]*\#?.* + [ ]*\.\.\.[ ]*\#?.* [coverage:run] omit = .venv/*,tests/*,docs/*,setup.py,.tox/* @@ -34,7 +36,7 @@ testpaths = src tests # WPS305 no f strings allowed # WPS337 ignore multiline condition violations # WPS348 ignore lines starting with a dot as black does this -ignore = W503,E203,B950,E501,C81,WPS210,WPS213,WPS305,WPS337,WPS348 +ignore = W503,E203,E266,E501,B950,C81,WPS210,WPS213,WPS305,WPS337,WPS348 min-name-length = 3 max-try-body-length = 2 # emit a warning if the McCabe complexity of a function diff --git a/targets.mk b/targets.mk index 5f8e803..dfe9172 100644 --- a/targets.mk +++ b/targets.mk @@ -7,11 +7,13 @@ SHELL := /bin/bash CRUFT = $(PYTHON) -m cruft DOCS_SOURCE := ./docs/source DOCS_BUILD_DIR := ./docs/build +MIN_TEST_COV := 80 PIP = $(PYTHON) -m pip PIP_COMPILE = $(PYTHON) -m piptools compile --allow-unsafe --no-emit-index-url -q --no-emit-trusted-host PIP_SYNC = $(PYTHON) -m piptools sync PYTHON = $(SOURCE_VENV) python PYTHON_VERSION := 3.8 +RENDER_ALL_COGS = $(SOURCE_VENV) ./bin/render_all_cogs SOURCE_VENV = source $(VENV_ACTIVATE); SPHINX_APIDOC = $(SOURCE_VENV) sphinx-apidoc SPHINX_BUILD = $(SOURCE_VENV) sphinx-build @@ -28,18 +30,22 @@ define runtests -vv \ --cov=src/logrus \ --cov-config=setup.cfg \ - --cov-fail-under=80 \ + --cov-fail-under=$(MIN_TEST_COV) \ --cov-report=xml:coverage.xml \ --cov-report=term-missing \ --cov-branch \ --doctest-modules \ --doctest-report ndiff \ - # Don't remove this comment! It allows us to end the last CLI option with a backslash. + # Don't remove this comment! endef .PHONY: all all: ## Build the package, build the docs, run all tests, and run all linters. -all: build build-docs lint test +all: build build-docs cogs lint test + +.PHONY: cogs +cogs: sync-dev-requirements + $(RENDER_ALL_COGS) .PHONY: lint lint: black isort pydocstyle flake8 mypy pylint quick-lints ## Run all linting checks. @@ -70,8 +76,11 @@ flake8: sync-dev-requirements ## Run flake8 checks. .PHONY: mypy mypy: sync-dev-requirements ## Run mypy checks. + @# HACK: Because mypy's cache has been terrible lately. + @rm -rf .mypy_cache $(PYTHON) -m mypy src - $(PYTHON) -m mypy tests + @# HACK: Fixes weird numpy error that seemed to happen randomly. + bash -c "$(SOURCE_VENV) { python -m mypy tests || python -m mypy tests; }" .PHONY: pylint pylint: sync-dev-requirements ## Run pylint checks.