From b66b9717e481db1b651728ffa0360a66a7a81512 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Fri, 4 Mar 2022 00:13:57 +0100 Subject: [PATCH] pyupgrade --- .pre-commit-config.yaml | 6 ++++++ CHANGELOG.md | 1 + matrix_webhook/formatters.py | 4 ++-- poetry.lock | 29 ++++++++++++++++++++++++++++- pyproject.toml | 1 + 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0821eef..7f3ebaf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,9 @@ repos: rev: 4.0.1 hooks: - id: flake8 +- repo: https://github.com/asottile/pyupgrade + rev: v2.31.0 + hooks: + - id: pyupgrade + args: + - --py38-plus diff --git a/CHANGELOG.md b/CHANGELOG.md index 10dedd3..ee16767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- add pyupgrade - add gitlab formatter for google chat & microsoft teams in [#21](https://github.com/nim65s/matrix-webhook/pull/21) by [@GhislainC](https://github.com/GhislainC) diff --git a/matrix_webhook/formatters.py b/matrix_webhook/formatters.py index d1d0519..eda4982 100644 --- a/matrix_webhook/formatters.py +++ b/matrix_webhook/formatters.py @@ -21,9 +21,9 @@ def github(data, headers): """Pretty-print a github notification.""" # TODO: Write nice useful formatters. This is only an example. if headers["X-GitHub-Event"] == "push": - pusher, ref, a, b, c = [ + pusher, ref, a, b, c = ( data[k] for k in ["pusher", "ref", "after", "before", "compare"] - ] + ) pusher = f"[@{pusher['name']}](https://github.com/{pusher['name']})" data["body"] = f"{pusher} pushed on {ref}: [{b} → {a}]({c}):\n\n" for commit in data["commits"]: diff --git a/poetry.lock b/poetry.lock index ad68afd..3a5c80a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -466,6 +466,17 @@ asyncio = ["async-timeout (>=3.0.1)"] curio = ["curio (>=1.4)"] trio = ["trio (>=0.16.0)"] +[[package]] +name = "pyupgrade" +version = "2.31.0" +description = "A tool to automatically upgrade syntax for newer versions." +category = "dev" +optional = false +python-versions = ">=3.6.1" + +[package.dependencies] +tokenize-rt = ">=3.2.0" + [[package]] name = "rfc3986" version = "1.5.0" @@ -504,6 +515,14 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "tokenize-rt" +version = "4.2.1" +description = "A wrapper around the stdlib `tokenize` which roundtrips." +category = "dev" +optional = false +python-versions = ">=3.6.1" + [[package]] name = "tomli" version = "1.2.3" @@ -555,7 +574,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "54f494bc284f796f48f53553f3e581e92268db6fb499a72f671d8c34b21b1942" +content-hash = "bd4a6605b9ddf79a0f70a141e780ce321f9c22d65d5c983fdc887796184456b4" [metadata.files] aiofiles = [ @@ -1001,6 +1020,10 @@ python-socks = [ {file = "python-socks-1.2.4.tar.gz", hash = "sha256:7d0ef2578cead9f762b71317d25a6c118fabaf79535555e75b3e102f5158ddd8"}, {file = "python_socks-1.2.4-py3-none-any.whl", hash = "sha256:9f12e8fe78629b87543fad0e4ea0ccf103a4fad6a7872c5d0ecb36d9903fa548"}, ] +pyupgrade = [ + {file = "pyupgrade-2.31.0-py2.py3-none-any.whl", hash = "sha256:0a62c5055f854d7f36e155b7ee8920561bf0399c53edd975cf02436eef8937fc"}, + {file = "pyupgrade-2.31.0.tar.gz", hash = "sha256:80e2308cae2b11c3fdd091137495d99abf7e0cd98b501aa5758974991497c24c"}, +] rfc3986 = [ {file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"}, {file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, @@ -1017,6 +1040,10 @@ snowballstemmer = [ {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, ] +tokenize-rt = [ + {file = "tokenize_rt-4.2.1-py2.py3-none-any.whl", hash = "sha256:08a27fa032a81cf45e8858d0ac706004fcd523e8463415ddf1442be38e204ea8"}, + {file = "tokenize_rt-4.2.1.tar.gz", hash = "sha256:0d4f69026fed520f8a1e0103aa36c406ef4661417f20ca643f913e33531b3b94"}, +] tomli = [ {file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"}, {file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"}, diff --git a/pyproject.toml b/pyproject.toml index 2994446..97dab39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ coverage = "^5.5" black = "^21.6b0" pydocstyle = "^6.1.1" flake8 = "^3.9.2" +pyupgrade = "^2.31.0" [tool.pydocstyle] ignore = ["D200", "D203", "D204", "D212"]