From 5a86e0ac4c58a29c68349cc48d040bc49885e9fd Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 6 May 2020 13:00:06 +0300 Subject: [PATCH 1/3] feat: add pre-commit hook support --- .isort.cfg | 2 + .pre-commit-config.yaml | 26 ++++++++ poetry.lock | 132 +++++++++++++++++++++++++++++++++++++--- pyproject.toml | 1 + 4 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 .isort.cfg create mode 100644 .pre-commit-config.yaml diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..6dbbdc21 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +known_third_party = aiofiles,aiohttp,aiohttp_socks,aresponses,async_lru,pydantic,pytest,typing_extensions diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..17ed6d92 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +repos: + - repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + language_version: python3.7 + files: aiogram + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: flake8 + args: ['--config=.flake8'] + files: aiogram + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-merge-conflict + + - repo: https://github.com/asottile/seed-isort-config + rev: master + hooks: + - id: seed-isort-config + + - repo: https://github.com/pre-commit/mirrors-isort + rev: master # pick the isort version you'd like to use from https://github.com/pre-commit/mirrors-isort/releases + hooks: + - id: isort diff --git a/poetry.lock b/poetry.lock index ca646b19..83eca828 100644 --- a/poetry.lock +++ b/poetry.lock @@ -37,7 +37,7 @@ aiohttp = ">=2.3.2" attrs = ">=19.2.0" [[package]] -category = "dev" +category = "main" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." name = "appdirs" optional = false @@ -152,6 +152,14 @@ typed-ast = ">=1.4.0" [package.extras] d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] +[[package]] +category = "main" +description = "Validate configuration and produce human readable error messages." +name = "cfgv" +optional = false +python-versions = ">=3.6.1" +version = "3.1.0" + [[package]] category = "main" description = "Universal encoding detector for Python 2 and 3" @@ -196,6 +204,14 @@ optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*" version = "4.4.2" +[[package]] +category = "main" +description = "Distribution utilities" +name = "distlib" +optional = false +python-versions = "*" +version = "0.3.0" + [[package]] category = "dev" description = "Discover and load entry points from installed packages." @@ -204,6 +220,14 @@ optional = false python-versions = ">=2.7" version = "0.3" +[[package]] +category = "main" +description = "A platform independent file lock." +name = "filelock" +optional = false +python-versions = "*" +version = "3.0.12" + [[package]] category = "dev" description = "the modular source code checker: pep8, pyflakes and co" @@ -239,6 +263,17 @@ optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" version = "0.18.2" +[[package]] +category = "main" +description = "File identification library for Python" +name = "identify" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +version = "1.4.15" + +[package.extras] +license = ["editdistance"] + [[package]] category = "main" description = "Internationalized Domain Names in Applications (IDNA)" @@ -248,7 +283,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.9" [[package]] -category = "dev" +category = "main" description = "Read metadata from Python packages" marker = "python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\"" name = "importlib-metadata" @@ -544,6 +579,14 @@ plot = ["matplotlib"] tgrep = ["pyparsing"] twitter = ["twython"] +[[package]] +category = "main" +description = "Node.js virtual environment builder" +name = "nodeenv" +optional = false +python-versions = "*" +version = "1.3.5" + [[package]] category = "dev" description = "Core utilities for Python packages" @@ -611,6 +654,26 @@ version = ">=0.12" [package.extras] dev = ["pre-commit", "tox"] +[[package]] +category = "main" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +name = "pre-commit" +optional = false +python-versions = ">=3.6.1" +version = "2.3.0" + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +toml = "*" +virtualenv = ">=15.2" + +[package.dependencies.importlib-metadata] +python = "<3.8" +version = "*" + [[package]] category = "dev" description = "Library for building powerful interactive command lines in Python" @@ -817,11 +880,11 @@ python-versions = "*" version = "2020.1" [[package]] -category = "dev" +category = "main" description = "YAML parser and emitter for Python" name = "pyyaml" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = "*" version = "5.3.1" [[package]] @@ -833,7 +896,7 @@ python-versions = "*" version = "2020.4.4" [[package]] -category = "dev" +category = "main" description = "Python 2 and 3 compatibility utilities" name = "six" optional = false @@ -841,7 +904,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" version = "1.14.0" [[package]] -category = "dev" +category = "main" description = "Python Library for Tom's Obvious, Minimal Language" name = "toml" optional = false @@ -908,6 +971,28 @@ optional = false python-versions = "*" version = "0.14.0" +[[package]] +category = "main" +description = "Virtual Python Environment builder" +name = "virtualenv" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +version = "20.0.20" + +[package.dependencies] +appdirs = ">=1.4.3,<2" +distlib = ">=0.3.0,<1" +filelock = ">=3.0.0,<4" +six = ">=1.9.0,<2" + +[package.dependencies.importlib-metadata] +python = "<3.8" +version = ">=0.12,<2" + +[package.extras] +docs = ["sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=19.9.0rc1)", "proselint (>=0.10.2)"] +testing = ["pytest (>=4)", "coverage (>=5)", "coverage-enable-subprocess (>=1)", "pytest-xdist (>=1.31.0)", "pytest-mock (>=2)", "pytest-env (>=0.6.2)", "pytest-randomly (>=1)", "pytest-timeout", "packaging (>=20.0)", "xonsh (>=0.9.16)"] + [[package]] category = "dev" description = "Measures number of Terminal column cells of wide-character codes" @@ -929,7 +1014,7 @@ idna = ">=2.0" multidict = ">=4.0" [[package]] -category = "dev" +category = "main" description = "Backport of pathlib-compatible object wrapper for zip files" marker = "python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\" or python_version >= \"3.5\" and python_version < \"3.8\" and (python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\")" name = "zipp" @@ -946,7 +1031,7 @@ fast = ["uvloop"] proxy = ["aiohttp-socks"] [metadata] -content-hash = "cd83723d922c4c0a645ef6f9f78447f83f2c1a933be928f8174ef897970acb2a" +content-hash = "c5cd681af0d4bb63e18555719eba352e44e0e05fde3f137a4fcb3a98277e1dc5" python-versions = "^3.7" [metadata.files] @@ -1015,6 +1100,10 @@ black = [ {file = "black-19.10b0-py36-none-any.whl", hash = "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b"}, {file = "black-19.10b0.tar.gz", hash = "sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539"}, ] +cfgv = [ + {file = "cfgv-3.1.0-py2.py3-none-any.whl", hash = "sha256:1ccf53320421aeeb915275a196e23b3b8ae87dea8ac6698b1638001d4a486d53"}, + {file = "cfgv-3.1.0.tar.gz", hash = "sha256:c8e8f552ffcc6194f4e18dd4f68d9aef0c0d58ae7e7be8c82bee3c5e9edfa513"}, +] chardet = [ {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, @@ -1064,10 +1153,17 @@ decorator = [ {file = "decorator-4.4.2-py2.py3-none-any.whl", hash = "sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760"}, {file = "decorator-4.4.2.tar.gz", hash = "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"}, ] +distlib = [ + {file = "distlib-0.3.0.zip", hash = "sha256:2e166e231a26b36d6dfe35a48c4464346620f8645ed0ace01ee31822b288de21"}, +] entrypoints = [ {file = "entrypoints-0.3-py2.py3-none-any.whl", hash = "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19"}, {file = "entrypoints-0.3.tar.gz", hash = "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"}, ] +filelock = [ + {file = "filelock-3.0.12-py3-none-any.whl", hash = "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836"}, + {file = "filelock-3.0.12.tar.gz", hash = "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59"}, +] flake8 = [ {file = "flake8-3.7.9-py2.py3-none-any.whl", hash = "sha256:49356e766643ad15072a789a20915d3c91dc89fd313ccd71802303fd67e4deca"}, {file = "flake8-3.7.9.tar.gz", hash = "sha256:45681a117ecc81e870cbf1262835ae4af5e7a8b08e40b944a8a6e6b895914cfb"}, @@ -1079,6 +1175,10 @@ flake8-html = [ future = [ {file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"}, ] +identify = [ + {file = "identify-1.4.15-py2.py3-none-any.whl", hash = "sha256:88ed90632023e52a6495749c6732e61e08ec9f4f04e95484a5c37b9caf40283c"}, + {file = "identify-1.4.15.tar.gz", hash = "sha256:23c18d97bb50e05be1a54917ee45cc61d57cb96aedc06aabb2b02331edf0dbf0"}, +] idna = [ {file = "idna-2.9-py2.py3-none-any.whl", hash = "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"}, {file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"}, @@ -1183,6 +1283,11 @@ markupsafe = [ {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"}, {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"}, ] mccabe = [ @@ -1246,6 +1351,9 @@ mypy-extensions = [ nltk = [ {file = "nltk-3.5.zip", hash = "sha256:845365449cd8c5f9731f7cb9f8bd6fd0767553b9d53af9eb1b3abf7700936b35"}, ] +nodeenv = [ + {file = "nodeenv-1.3.5-py2.py3-none-any.whl", hash = "sha256:5b2438f2e42af54ca968dd1b374d14a1194848955187b0e5e4be1f73813a5212"}, +] packaging = [ {file = "packaging-20.3-py2.py3-none-any.whl", hash = "sha256:82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752"}, {file = "packaging-20.3.tar.gz", hash = "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3"}, @@ -1270,6 +1378,10 @@ pluggy = [ {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, ] +pre-commit = [ + {file = "pre_commit-2.3.0-py2.py3-none-any.whl", hash = "sha256:979b53dab1af35063a483bfe13b0fcbbf1a2cf8c46b60e0a9a8d08e8269647a1"}, + {file = "pre_commit-2.3.0.tar.gz", hash = "sha256:f3e85e68c6d1cbe7828d3471896f1b192cfcf1c4d83bf26e26beeb5941855257"}, +] prompt-toolkit = [ {file = "prompt_toolkit-3.0.5-py3-none-any.whl", hash = "sha256:df7e9e63aea609b1da3a65641ceaf5bc7d05e0a04de5bd45d05dbeffbabf9e04"}, {file = "prompt_toolkit-3.0.5.tar.gz", hash = "sha256:563d1a4140b63ff9dd587bda9557cffb2fe73650205ab6f4383092fb882e7dc8"}, @@ -1456,6 +1568,10 @@ uvloop = [ {file = "uvloop-0.14.0-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:4315d2ec3ca393dd5bc0b0089d23101276778c304d42faff5dc4579cb6caef09"}, {file = "uvloop-0.14.0.tar.gz", hash = "sha256:123ac9c0c7dd71464f58f1b4ee0bbd81285d96cdda8bc3519281b8973e3a461e"}, ] +virtualenv = [ + {file = "virtualenv-20.0.20-py2.py3-none-any.whl", hash = "sha256:b4c14d4d73a0c23db267095383c4276ef60e161f94fde0427f2f21a0132dde74"}, + {file = "virtualenv-20.0.20.tar.gz", hash = "sha256:fd0e54dec8ac96c1c7c87daba85f0a59a7c37fe38748e154306ca21c73244637"}, +] wcwidth = [ {file = "wcwidth-0.1.9-py2.py3-none-any.whl", hash = "sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1"}, {file = "wcwidth-0.1.9.tar.gz", hash = "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"}, diff --git a/pyproject.toml b/pyproject.toml index 5e1812bb..d73afdb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ uvloop = {version = "^0.14.0", markers = "sys_platform == 'darwin' or sys_platfo async_lru = "^1.0" aiohttp-socks = {version = "^0.3.8", optional = true} typing-extensions = "^3.7.4" +pre-commit = "^2.3.0" [tool.poetry.dev-dependencies] uvloop = {version = "^0.14.0", markers = "sys_platform == 'darwin' or sys_platform == 'linux'"} From 46957d731f69075ec280f67acaa53a2c09563274 Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 6 May 2020 13:04:40 +0300 Subject: [PATCH 2/3] feat: add mypy hook --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17ed6d92..7cc2e700 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,3 +24,8 @@ repos: rev: master # pick the isort version you'd like to use from https://github.com/pre-commit/mirrors-isort/releases hooks: - id: isort + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v0.770' # pick sha/tag from https://github.com/pre-commit/mirrors-mypy + hooks: + - id: mypy From 17a07f10dc5f218b992a879fb61e21f106c1374d Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 6 May 2020 17:27:51 +0300 Subject: [PATCH 3/3] fix: make pre-commit a dev requirement --- poetry.lock | 28 ++++++++++++++-------------- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/poetry.lock b/poetry.lock index 83eca828..621e0e86 100644 --- a/poetry.lock +++ b/poetry.lock @@ -37,7 +37,7 @@ aiohttp = ">=2.3.2" attrs = ">=19.2.0" [[package]] -category = "main" +category = "dev" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." name = "appdirs" optional = false @@ -153,7 +153,7 @@ typed-ast = ">=1.4.0" d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] [[package]] -category = "main" +category = "dev" description = "Validate configuration and produce human readable error messages." name = "cfgv" optional = false @@ -205,7 +205,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*" version = "4.4.2" [[package]] -category = "main" +category = "dev" description = "Distribution utilities" name = "distlib" optional = false @@ -221,7 +221,7 @@ python-versions = ">=2.7" version = "0.3" [[package]] -category = "main" +category = "dev" description = "A platform independent file lock." name = "filelock" optional = false @@ -264,7 +264,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" version = "0.18.2" [[package]] -category = "main" +category = "dev" description = "File identification library for Python" name = "identify" optional = false @@ -283,7 +283,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "2.9" [[package]] -category = "main" +category = "dev" description = "Read metadata from Python packages" marker = "python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\"" name = "importlib-metadata" @@ -580,7 +580,7 @@ tgrep = ["pyparsing"] twitter = ["twython"] [[package]] -category = "main" +category = "dev" description = "Node.js virtual environment builder" name = "nodeenv" optional = false @@ -655,7 +655,7 @@ version = ">=0.12" dev = ["pre-commit", "tox"] [[package]] -category = "main" +category = "dev" description = "A framework for managing and maintaining multi-language pre-commit hooks." name = "pre-commit" optional = false @@ -880,7 +880,7 @@ python-versions = "*" version = "2020.1" [[package]] -category = "main" +category = "dev" description = "YAML parser and emitter for Python" name = "pyyaml" optional = false @@ -896,7 +896,7 @@ python-versions = "*" version = "2020.4.4" [[package]] -category = "main" +category = "dev" description = "Python 2 and 3 compatibility utilities" name = "six" optional = false @@ -904,7 +904,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" version = "1.14.0" [[package]] -category = "main" +category = "dev" description = "Python Library for Tom's Obvious, Minimal Language" name = "toml" optional = false @@ -972,7 +972,7 @@ python-versions = "*" version = "0.14.0" [[package]] -category = "main" +category = "dev" description = "Virtual Python Environment builder" name = "virtualenv" optional = false @@ -1014,7 +1014,7 @@ idna = ">=2.0" multidict = ">=4.0" [[package]] -category = "main" +category = "dev" description = "Backport of pathlib-compatible object wrapper for zip files" marker = "python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\" or python_version >= \"3.5\" and python_version < \"3.8\" and (python_version >= \"3.5\" and python_version < \"3.8\" or python_version < \"3.8\")" name = "zipp" @@ -1031,7 +1031,7 @@ fast = ["uvloop"] proxy = ["aiohttp-socks"] [metadata] -content-hash = "c5cd681af0d4bb63e18555719eba352e44e0e05fde3f137a4fcb3a98277e1dc5" +content-hash = "0b325d34fff06035598724438d816a4bd1aba992e21b2fdef10ab5fafa59ff2c" python-versions = "^3.7" [metadata.files] diff --git a/pyproject.toml b/pyproject.toml index d73afdb2..15d5fb43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,6 @@ uvloop = {version = "^0.14.0", markers = "sys_platform == 'darwin' or sys_platfo async_lru = "^1.0" aiohttp-socks = {version = "^0.3.8", optional = true} typing-extensions = "^3.7.4" -pre-commit = "^2.3.0" [tool.poetry.dev-dependencies] uvloop = {version = "^0.14.0", markers = "sys_platform == 'darwin' or sys_platform == 'linux'"} @@ -67,6 +66,7 @@ lxml = "^4.4" ipython = "^7.10" markdown-include = "^0.5.1" aiohttp-socks = "^0.3.4" +pre-commit = "^2.3.0" [tool.poetry.extras] fast = ["uvloop"]