Skip to content

Commit db93a85

Browse files
authoredNov 24, 2023
Switch to ruff (#672)
1 parent e4a4b6d commit db93a85

File tree

7 files changed

+25
-39
lines changed

7 files changed

+25
-39
lines changed
 

‎pyproject.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ requires = [
99
# disable Pip's fallback guessing
1010
build-backend = "setuptools.build_meta"
1111

12-
[tool.black]
12+
[tool.ruff]
13+
ignore = ['N818']
14+
select = ['E', 'F', 'I', 'N', 'W', 'UP', 'RUF']
1315
line-length = 79
14-
target-version = ["py37"]
16+
17+
[tool.ruff.isort]
18+
known-first-party = ["bcrypt", "tests"]

‎release.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
33
# for complete details.
44

5-
from __future__ import absolute_import, division, print_function
65

76
import getpass
87
import io
@@ -13,12 +12,11 @@
1312
import zipfile
1413

1514
import click
16-
1715
import requests
1816

1917

2018
def run(*args, **kwargs):
21-
print("[running] {0}".format(list(args)))
19+
print(f"[running] {list(args)}")
2220
subprocess.check_call(list(args), **kwargs)
2321

2422

@@ -28,7 +26,7 @@ def wait_for_build_complete_github_actions(session, token, run_url):
2826
run_url,
2927
headers={
3028
"Content-Type": "application/json",
31-
"Authorization": "token {}".format(token),
29+
"Authorization": f"token {token}",
3230
},
3331
)
3432
response.raise_for_status()
@@ -42,7 +40,7 @@ def download_artifacts_github_actions(session, token, run_url):
4240
run_url,
4341
headers={
4442
"Content-Type": "application/json",
45-
"Authorization": "token {}".format(token),
43+
"Authorization": f"token {token}",
4644
},
4745
)
4846
response.raise_for_status()
@@ -51,7 +49,7 @@ def download_artifacts_github_actions(session, token, run_url):
5149
response.json()["artifacts_url"],
5250
headers={
5351
"Content-Type": "application/json",
54-
"Authorization": "token {}".format(token),
52+
"Authorization": f"token {token}",
5553
},
5654
)
5755
response.raise_for_status()
@@ -61,7 +59,7 @@ def download_artifacts_github_actions(session, token, run_url):
6159
artifact["archive_download_url"],
6260
headers={
6361
"Content-Type": "application/json",
64-
"Authorization": "token {}".format(token),
62+
"Authorization": f"token {token}",
6563
},
6664
)
6765
with zipfile.ZipFile(io.BytesIO(response.content)) as z:
@@ -89,7 +87,7 @@ def build_github_actions_sdist_wheels(token, version):
8987
headers={
9088
"Content-Type": "application/json",
9189
"Accept": "application/vnd.github.v3+json",
92-
"Authorization": "token {}".format(token),
90+
"Authorization": f"token {token}",
9391
},
9492
data=json.dumps({"ref": "main", "inputs": {"version": version}}),
9593
)
@@ -104,7 +102,7 @@ def build_github_actions_sdist_wheels(token, version):
104102
),
105103
headers={
106104
"Content-Type": "application/json",
107-
"Authorization": "token {}".format(token),
105+
"Authorization": f"token {token}",
108106
},
109107
)
110108
response.raise_for_status()
@@ -121,7 +119,7 @@ def release(version):
121119
"""
122120
github_token = getpass.getpass("Github person access token: ")
123121

124-
run("git", "tag", "-s", version, "-m", "{0} release".format(version))
122+
run("git", "tag", "-s", version, "-m", f"{version} release")
125123
run("git", "push", "--tags")
126124

127125
github_actions_paths = build_github_actions_sdist_wheels(

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
),
4949
],
5050
)
51-
except: # noqa: E722
51+
except:
5252
# Note: This is a bare exception that re-raises so that we don't interfere
5353
# with anything the installation machinery might want to do. Because we
5454
# print this for any exception this msg can appear (e.g. in verbose logs)

‎src/bcrypt/__about__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
from __future__ import absolute_import
17-
from __future__ import division
18-
from __future__ import unicode_literals
1916

2017
__all__ = [
2118
"__title__",
@@ -38,4 +35,4 @@
3835
__email__ = "cryptography-dev@python.org"
3936

4037
__license__ = "Apache License, Version 2.0"
41-
__copyright__ = "Copyright 2013-2022 {0}".format(__author__)
38+
__copyright__ = f"Copyright 2013-2023 {__author__}"

‎src/bcrypt/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
from __future__ import absolute_import
17-
from __future__ import division
1816

17+
from . import _bcrypt
1918
from .__about__ import (
2019
__author__,
2120
__copyright__,
@@ -26,8 +25,6 @@
2625
__uri__,
2726
__version__,
2827
)
29-
from . import _bcrypt # noqa: I100
30-
3128

3229
__all__ = [
3330
"__title__",

‎tests/test_bcrypt.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import bcrypt
44

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

‎tox.ini

+3-12
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ commands =
1515

1616
[testenv:pep8]
1717
deps =
18-
black
19-
flake8
20-
flake8-import-order
21-
pep8-naming
18+
ruff
2219
commands =
23-
flake8 .
24-
black --check .
20+
ruff .
21+
ruff format --check .
2522

2623
[testenv:mypy]
2724
deps =
@@ -39,12 +36,6 @@ commands =
3936
python setup.py check --metadata --restructuredtext --strict
4037

4138

42-
[flake8]
43-
ignore = E203,E211,E501,W503,W504
44-
exclude = .tox,*.egg
45-
select = E,W,F,N,I
46-
application-import-names = bcrypt,tests
47-
4839
[check-manifest]
4940
ignore =
5041
tests/reference/*

0 commit comments

Comments
 (0)
Please sign in to comment.