Skip to content

Commit

Permalink
Switch to ruff (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex authored Nov 24, 2023
1 parent e4a4b6d commit db93a85
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 39 deletions.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
18 changes: 8 additions & 10 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,12 +12,11 @@
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)


Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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}}),
)
Expand All @@ -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()
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
),
],
)
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)
Expand Down
5 changes: 1 addition & 4 deletions src/bcrypt/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__",
Expand All @@ -38,4 +35,4 @@
__email__ = "cryptography-dev@python.org"

__license__ = "Apache License, Version 2.0"
__copyright__ = "Copyright 2013-2022 {0}".format(__author__)
__copyright__ = f"Copyright 2013-2023 {__author__}"
5 changes: 1 addition & 4 deletions src/bcrypt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand All @@ -26,8 +25,6 @@
__uri__,
__version__,
)
from . import _bcrypt # noqa: I100


__all__ = [
"__title__",
Expand Down
11 changes: 5 additions & 6 deletions tests/test_bcrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import bcrypt


_test_vectors = [
(
b"Kk4DQuMMfZL9o",
Expand Down Expand Up @@ -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",
],
Expand Down
15 changes: 3 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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/*

0 comments on commit db93a85

Please sign in to comment.