Switch to ruff (#672)

This commit is contained in:
Alex Gaynor 2023-11-23 20:48:17 -05:00 committed by GitHub
parent e4a4b6dd73
commit db93a85d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 39 deletions

View File

@ -9,6 +9,10 @@ requires = [
# disable Pip's fallback guessing
build-backend = "setuptools.build_meta"
[tool.black]
[tool.ruff]
ignore = ['N818']
select = ['E', 'F', 'I', 'N', 'W', 'UP', 'RUF']
line-length = 79
target-version = ["py37"]
[tool.ruff.isort]
known-first-party = ["bcrypt", "tests"]

View File

@ -2,7 +2,6 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
import getpass
import io
@ -13,12 +12,11 @@ import time
import zipfile
import click
import requests
def run(*args, **kwargs):
print("[running] {0}".format(list(args)))
print(f"[running] {list(args)}")
subprocess.check_call(list(args), **kwargs)
@ -28,7 +26,7 @@ def wait_for_build_complete_github_actions(session, token, run_url):
run_url,
headers={
"Content-Type": "application/json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
)
response.raise_for_status()
@ -42,7 +40,7 @@ def download_artifacts_github_actions(session, token, run_url):
run_url,
headers={
"Content-Type": "application/json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
)
response.raise_for_status()
@ -51,7 +49,7 @@ def download_artifacts_github_actions(session, token, run_url):
response.json()["artifacts_url"],
headers={
"Content-Type": "application/json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
)
response.raise_for_status()
@ -61,7 +59,7 @@ def download_artifacts_github_actions(session, token, run_url):
artifact["archive_download_url"],
headers={
"Content-Type": "application/json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
)
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
@ -89,7 +87,7 @@ def build_github_actions_sdist_wheels(token, version):
headers={
"Content-Type": "application/json",
"Accept": "application/vnd.github.v3+json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
data=json.dumps({"ref": "main", "inputs": {"version": version}}),
)
@ -104,7 +102,7 @@ def build_github_actions_sdist_wheels(token, version):
),
headers={
"Content-Type": "application/json",
"Authorization": "token {}".format(token),
"Authorization": f"token {token}",
},
)
response.raise_for_status()
@ -121,7 +119,7 @@ def release(version):
"""
github_token = getpass.getpass("Github person access token: ")
run("git", "tag", "-s", version, "-m", "{0} release".format(version))
run("git", "tag", "-s", version, "-m", f"{version} release")
run("git", "push", "--tags")
github_actions_paths = build_github_actions_sdist_wheels(

View File

@ -48,7 +48,7 @@ try:
),
],
)
except: # noqa: E722
except:
# Note: This is a bare exception that re-raises so that we don't interfere
# with anything the installation machinery might want to do. Because we
# print this for any exception this msg can appear (e.g. in verbose logs)

View File

@ -13,9 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
__all__ = [
"__title__",
@ -38,4 +35,4 @@ __author__ = "The Python Cryptographic Authority developers"
__email__ = "cryptography-dev@python.org"
__license__ = "Apache License, Version 2.0"
__copyright__ = "Copyright 2013-2022 {0}".format(__author__)
__copyright__ = f"Copyright 2013-2023 {__author__}"

View File

@ -13,9 +13,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import division
from . import _bcrypt
from .__about__ import (
__author__,
__copyright__,
@ -26,8 +25,6 @@ from .__about__ import (
__uri__,
__version__,
)
from . import _bcrypt # noqa: I100
__all__ = [
"__title__",

View File

@ -2,7 +2,6 @@ import pytest
import bcrypt
_test_vectors = [
(
b"Kk4DQuMMfZL9o",
@ -393,13 +392,13 @@ def test_checkpw_extra_data():
[
# longer password
8,
b"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
b"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
b"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do"
b" eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
b"enim ad minim veniam, quis nostrud exercitation ullamco laboris "
b"nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor "
b"in reprehenderit in voluptate velit esse cillum dolore eu fugiat "
b"nulla pariatur. Excepteur sint occaecat cupidatat non proident, "
b"sunt in culpa qui officia deserunt mollit anim id est laborum.",
b"in reprehenderit in voluptate velit esse cillum dolore eu fugiat"
b" nulla pariatur. Excepteur sint occaecat cupidatat non proident,"
b" sunt in culpa qui officia deserunt mollit anim id est laborum.",
b"salis\x00",
b"\x10\x97\x8b\x07\x25\x3d\xf5\x7f\x71\xa1\x62\xeb\x0e\x8a\xd3\x0a",
],

15
tox.ini
View File

@ -15,13 +15,10 @@ commands =
[testenv:pep8]
deps =
black
flake8
flake8-import-order
pep8-naming
ruff
commands =
flake8 .
black --check .
ruff .
ruff format --check .
[testenv:mypy]
deps =
@ -39,12 +36,6 @@ commands =
python setup.py check --metadata --restructuredtext --strict
[flake8]
ignore = E203,E211,E501,W503,W504
exclude = .tox,*.egg
select = E,W,F,N,I
application-import-names = bcrypt,tests
[check-manifest]
ignore =
tests/reference/*