Skip to content

Commit 367297f

Browse files
authored
Merge pull request #378 from EasyPost/EXP-765_ruff
chore: migrate to ruff
2 parents 763ec75 + d7c20a6 commit 367297f

4 files changed

Lines changed: 14 additions & 49 deletions

File tree

Makefile

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ TEST_DIR := tests
88
help:
99
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
1010

11-
## black - Runs the Black Python formatter against the project
12-
black:
13-
$(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/
14-
15-
## black-check - Checks if the project is formatted correctly against the Black rules
16-
black-check:
17-
$(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --check
18-
1911
## build - Builds the project in preparation for release
2012
build:
2113
$(VIRTUAL_BIN)/python -m build
@@ -33,10 +25,6 @@ coverage:
3325
docs:
3426
$(VIRTUAL_BIN)/pdoc $(PROJECT_NAME) -o docs
3527

36-
## flake8 - Lint the project with flake8
37-
flake8:
38-
$(VIRTUAL_BIN)/flake8 $(PROJECT_NAME)/ $(TEST_DIR)/
39-
4028
## init-examples-submodule - Initialize the examples submodule
4129
init-examples-submodule:
4230
git submodule init
@@ -52,19 +40,15 @@ update-examples-submodule:
5240
git submodule init
5341
git submodule update --remote
5442

55-
## isort - Sorts imports throughout the project
56-
isort:
57-
$(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/
58-
59-
## isort-check - Checks that imports throughout the project are sorted correctly
60-
isort-check:
61-
$(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --check-only
62-
63-
## lint - Run linters on the project
64-
lint: black-check isort-check flake8 mypy scan
43+
## lint - Lints the project
44+
lint:
45+
$(VIRTUAL_BIN)/ruff check $(PROJECT_NAME)/ $(TEST_DIR)/
46+
$(VIRTUAL_BIN)/ruff format --check $(PROJECT_NAME)/ $(TEST_DIR)/
6547

66-
## lint-fix - Runs all formatting tools against the project
67-
lint-fix: black isort
48+
## lint-fix - Fixes lint issues
49+
lint-fix:
50+
$(VIRTUAL_BIN)/ruff check --fix $(PROJECT_NAME)/ $(TEST_DIR)/
51+
$(VIRTUAL_BIN)/ruff format $(PROJECT_NAME)/ $(TEST_DIR)/
6852

6953
## mypy - Run mypy type checking on the project
7054
mypy:
@@ -84,4 +68,4 @@ scan:
8468
test:
8569
$(VIRTUAL_BIN)/pytest
8670

87-
.PHONY: help black black-check build clean coverage docs flake8 install isort isort-check lint lint-fix mypy release scan test
71+
.PHONY: help build clean coverage docs install lint lint-fix mypy release scan test

easypost/easypost_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def convert_to_easypost_object(
7373
# Dynamically import class models due to circular imports of EasyPostObject
7474
class_model = (
7575
getattr(
76-
importlib.import_module(f'easypost.models.{re.sub(r"(?<!^)(?=[A-Z])", "_", class_name).lower()}'),
76+
importlib.import_module(f"easypost.models.{re.sub(r'(?<!^)(?=[A-Z])', '_', class_name).lower()}"),
7777
class_name,
7878
)
7979
if class_name != EasyPostObject

pyproject.toml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@ classifiers = [
2727
dependencies = ["requests >= 2.4.3"]
2828
optional-dependencies = { dev = [
2929
"bandit == 1.8.*",
30-
"black == 25.*",
3130
"build == 1.2.*",
32-
"flake8 == 6.*",
33-
"Flake8-pyproject == 1.2.*",
34-
"isort == 6.*",
3531
"mypy == 1.15.*",
3632
"pdoc == 15.*",
33+
"pytest == 8.*",
3734
"pytest-cov == 6.*",
3835
"pytest-vcr == 1.*",
39-
"pytest == 8.*",
36+
"ruff == 0.14.*",
4037
"vcrpy == 7.*",
4138
] }
4239

@@ -51,21 +48,5 @@ exclude = ["docs", "examples", "tests"]
5148
[tool.setuptools.package-data]
5249
easypost = ["py.typed"]
5350

54-
[tool.black]
51+
[tool.ruff]
5552
line-length = 120
56-
57-
[tool.isort]
58-
profile = "black"
59-
line_length = 120
60-
indent = 4
61-
force_grid_wrap = 2
62-
multi_line_output = 3
63-
sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
64-
lines_after_imports = 2
65-
include_trailing_comma = true
66-
use_parentheses = true
67-
68-
[tool.flake8]
69-
max-line-length = 120
70-
extend-ignore = ["E203", "F821"]
71-
per-file-ignores = "__init__.py:F401"

tests/test_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def assert_request(**kwargs):
1212
assert kwargs.get("path") == "https://api.easypost.com/v2/parcels"
1313
assert "parcel" in kwargs.get("request_body")
1414
assert "Authorization" in kwargs.get("headers")
15-
assert type(kwargs.get("request_timestamp")) == datetime.datetime
15+
assert isinstance(kwargs.get("request_timestamp"), datetime.datetime)
1616
assert uuid.UUID(str(kwargs.get("request_uuid")))
1717

1818
"""Test that we fire a RequestHook prior to making an HTTP request."""

0 commit comments

Comments
 (0)