pyupgrade

This commit is contained in:
Guilhem Saurel 2022-03-04 00:13:57 +01:00
parent c4e0bb76e9
commit b66b9717e4
5 changed files with 38 additions and 3 deletions

View file

@ -28,3 +28,9 @@ repos:
rev: 4.0.1 rev: 4.0.1
hooks: hooks:
- id: flake8 - id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args:
- --py38-plus

View file

@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
- add pyupgrade
- add gitlab formatter for google chat & microsoft teams - add gitlab formatter for google chat & microsoft teams
in [#21](https://github.com/nim65s/matrix-webhook/pull/21) in [#21](https://github.com/nim65s/matrix-webhook/pull/21)
by [@GhislainC](https://github.com/GhislainC) by [@GhislainC](https://github.com/GhislainC)

View file

@ -21,9 +21,9 @@ def github(data, headers):
"""Pretty-print a github notification.""" """Pretty-print a github notification."""
# TODO: Write nice useful formatters. This is only an example. # TODO: Write nice useful formatters. This is only an example.
if headers["X-GitHub-Event"] == "push": 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"] data[k] for k in ["pusher", "ref", "after", "before", "compare"]
] )
pusher = f"[@{pusher['name']}](https://github.com/{pusher['name']})" pusher = f"[@{pusher['name']}](https://github.com/{pusher['name']})"
data["body"] = f"{pusher} pushed on {ref}: [{b}{a}]({c}):\n\n" data["body"] = f"{pusher} pushed on {ref}: [{b}{a}]({c}):\n\n"
for commit in data["commits"]: for commit in data["commits"]:

29
poetry.lock generated
View file

@ -466,6 +466,17 @@ asyncio = ["async-timeout (>=3.0.1)"]
curio = ["curio (>=1.4)"] curio = ["curio (>=1.4)"]
trio = ["trio (>=0.16.0)"] 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]] [[package]]
name = "rfc3986" name = "rfc3986"
version = "1.5.0" version = "1.5.0"
@ -504,6 +515,14 @@ category = "dev"
optional = false optional = false
python-versions = "*" 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]] [[package]]
name = "tomli" name = "tomli"
version = "1.2.3" version = "1.2.3"
@ -555,7 +574,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "54f494bc284f796f48f53553f3e581e92268db6fb499a72f671d8c34b21b1942" content-hash = "bd4a6605b9ddf79a0f70a141e780ce321f9c22d65d5c983fdc887796184456b4"
[metadata.files] [metadata.files]
aiofiles = [ aiofiles = [
@ -1001,6 +1020,10 @@ python-socks = [
{file = "python-socks-1.2.4.tar.gz", hash = "sha256:7d0ef2578cead9f762b71317d25a6c118fabaf79535555e75b3e102f5158ddd8"}, {file = "python-socks-1.2.4.tar.gz", hash = "sha256:7d0ef2578cead9f762b71317d25a6c118fabaf79535555e75b3e102f5158ddd8"},
{file = "python_socks-1.2.4-py3-none-any.whl", hash = "sha256:9f12e8fe78629b87543fad0e4ea0ccf103a4fad6a7872c5d0ecb36d9903fa548"}, {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 = [ rfc3986 = [
{file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"}, {file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"},
{file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, {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-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"},
{file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, {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 = [ tomli = [
{file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"}, {file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"},
{file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"}, {file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"},

View file

@ -19,6 +19,7 @@ coverage = "^5.5"
black = "^21.6b0" black = "^21.6b0"
pydocstyle = "^6.1.1" pydocstyle = "^6.1.1"
flake8 = "^3.9.2" flake8 = "^3.9.2"
pyupgrade = "^2.31.0"
[tool.pydocstyle] [tool.pydocstyle]
ignore = ["D200", "D203", "D204", "D212"] ignore = ["D200", "D203", "D204", "D212"]