From d7c20a6acc21c566a312b90b33901d44d1c54e6f Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:24:41 -0700 Subject: [PATCH] chore: migrate to ruff --- Makefile | 34 +++++++++------------------------- easypost/easypost_object.py | 2 +- pyproject.toml | 25 +++---------------------- tests/test_hook.py | 2 +- 4 files changed, 14 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index ba9871a0..cc1b8526 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,6 @@ TEST_DIR := tests help: @cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t -## black - Runs the Black Python formatter against the project -black: - $(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ - -## black-check - Checks if the project is formatted correctly against the Black rules -black-check: - $(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --check - ## build - Builds the project in preparation for release build: $(VIRTUAL_BIN)/python -m build @@ -33,10 +25,6 @@ coverage: docs: $(VIRTUAL_BIN)/pdoc $(PROJECT_NAME) -o docs -## flake8 - Lint the project with flake8 -flake8: - $(VIRTUAL_BIN)/flake8 $(PROJECT_NAME)/ $(TEST_DIR)/ - ## init-examples-submodule - Initialize the examples submodule init-examples-submodule: git submodule init @@ -52,19 +40,15 @@ update-examples-submodule: git submodule init git submodule update --remote -## isort - Sorts imports throughout the project -isort: - $(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ - -## isort-check - Checks that imports throughout the project are sorted correctly -isort-check: - $(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --check-only - -## lint - Run linters on the project -lint: black-check isort-check flake8 mypy scan +## lint - Lints the project +lint: + $(VIRTUAL_BIN)/ruff check $(PROJECT_NAME)/ $(TEST_DIR)/ + $(VIRTUAL_BIN)/ruff format --check $(PROJECT_NAME)/ $(TEST_DIR)/ -## lint-fix - Runs all formatting tools against the project -lint-fix: black isort +## lint-fix - Fixes lint issues +lint-fix: + $(VIRTUAL_BIN)/ruff check --fix $(PROJECT_NAME)/ $(TEST_DIR)/ + $(VIRTUAL_BIN)/ruff format $(PROJECT_NAME)/ $(TEST_DIR)/ ## mypy - Run mypy type checking on the project mypy: @@ -84,4 +68,4 @@ scan: test: $(VIRTUAL_BIN)/pytest -.PHONY: help black black-check build clean coverage docs flake8 install isort isort-check lint lint-fix mypy release scan test +.PHONY: help build clean coverage docs install lint lint-fix mypy release scan test diff --git a/easypost/easypost_object.py b/easypost/easypost_object.py index 4643ab2e..63b590a9 100644 --- a/easypost/easypost_object.py +++ b/easypost/easypost_object.py @@ -73,7 +73,7 @@ def convert_to_easypost_object( # Dynamically import class models due to circular imports of EasyPostObject class_model = ( getattr( - importlib.import_module(f'easypost.models.{re.sub(r"(?= 2.4.3"] optional-dependencies = { dev = [ "bandit == 1.8.*", - "black == 25.*", "build == 1.2.*", - "flake8 == 6.*", - "Flake8-pyproject == 1.2.*", - "isort == 6.*", "mypy == 1.15.*", "pdoc == 15.*", + "pytest == 8.*", "pytest-cov == 6.*", "pytest-vcr == 1.*", - "pytest == 8.*", + "ruff == 0.14.*", "vcrpy == 7.*", ] } @@ -51,21 +48,5 @@ exclude = ["docs", "examples", "tests"] [tool.setuptools.package-data] easypost = ["py.typed"] -[tool.black] +[tool.ruff] line-length = 120 - -[tool.isort] -profile = "black" -line_length = 120 -indent = 4 -force_grid_wrap = 2 -multi_line_output = 3 -sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER" -lines_after_imports = 2 -include_trailing_comma = true -use_parentheses = true - -[tool.flake8] -max-line-length = 120 -extend-ignore = ["E203", "F821"] -per-file-ignores = "__init__.py:F401" diff --git a/tests/test_hook.py b/tests/test_hook.py index b02fc49b..44af38d5 100644 --- a/tests/test_hook.py +++ b/tests/test_hook.py @@ -12,7 +12,7 @@ def assert_request(**kwargs): assert kwargs.get("path") == "https://api.easypost.com/v2/parcels" assert "parcel" in kwargs.get("request_body") assert "Authorization" in kwargs.get("headers") - assert type(kwargs.get("request_timestamp")) == datetime.datetime + assert isinstance(kwargs.get("request_timestamp"), datetime.datetime) assert uuid.UUID(str(kwargs.get("request_uuid"))) """Test that we fire a RequestHook prior to making an HTTP request."""