diff --git a/.gitignore b/.gitignore index 88f80af..4a55e33 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,3 @@ Icon test venv virtualenv -/.flake8 -/pyproject.toml diff --git a/Makefile b/Makefile index 8b43916..ba9871a 100644 --- a/Makefile +++ b/Makefile @@ -10,11 +10,11 @@ help: ## black - Runs the Black Python formatter against the project black: - $(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --config examples/style_guides/python/pyproject.toml + $(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)/ --config examples/style_guides/python/pyproject.toml --check + $(VIRTUAL_BIN)/black $(PROJECT_NAME)/ $(TEST_DIR)/ --check ## build - Builds the project in preparation for release build: @@ -35,7 +35,7 @@ docs: ## flake8 - Lint the project with flake8 flake8: - $(VIRTUAL_BIN)/flake8 $(PROJECT_NAME)/ $(TEST_DIR)/ --append-config examples/style_guides/python/.flake8 + $(VIRTUAL_BIN)/flake8 $(PROJECT_NAME)/ $(TEST_DIR)/ ## init-examples-submodule - Initialize the examples submodule init-examples-submodule: @@ -54,11 +54,11 @@ update-examples-submodule: ## isort - Sorts imports throughout the project isort: - $(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --settings-file examples/style_guides/python/pyproject.toml + $(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)/ --settings-file examples/style_guides/python/pyproject.toml --check-only + $(VIRTUAL_BIN)/isort $(PROJECT_NAME)/ $(TEST_DIR)/ --check-only ## lint - Run linters on the project lint: black-check isort-check flake8 mypy scan @@ -68,7 +68,7 @@ lint-fix: black isort ## mypy - Run mypy type checking on the project mypy: - $(VIRTUAL_BIN)/mypy $(PROJECT_NAME)/ $(TEST_DIR)/ --config-file examples/style_guides/python/pyproject.toml --install-types --non-interactive + $(VIRTUAL_BIN)/mypy $(PROJECT_NAME)/ $(TEST_DIR)/ --install-types --non-interactive ## release - Cuts a release for the project on GitHub (requires GitHub CLI) # tag = The associated tag title of the release diff --git a/easypost/requestor.py b/easypost/requestor.py index 9f22b9e..5b92ba7 100644 --- a/easypost/requestor.py +++ b/easypost/requestor.py @@ -14,6 +14,7 @@ from urllib.parse import urlencode import requests + from easypost.constant import ( API_VERSION, COMMUNICATION_ERROR, diff --git a/easypost/services/referral_customer_service.py b/easypost/services/referral_customer_service.py index ff74bce..17a3c53 100644 --- a/easypost/services/referral_customer_service.py +++ b/easypost/services/referral_customer_service.py @@ -5,6 +5,7 @@ ) import requests + from easypost.constant import ( _FILTERS_KEY, SEND_STRIPE_DETAILS_ERROR, diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..aa8150b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "easypost" +description = "EasyPost Shipping API Client Library for Python" +version = "10.3.0" +readme = "README.md" +requires-python = ">=3.9" +license = { file = "LICENSE" } +authors = [{ name = "EasyPost", email = "support@easypost.com" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", + "Topic :: Software Development :: Libraries", +] +dependencies = ["requests >= 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-cov == 6.*", + "pytest-vcr == 1.*", + "pytest == 8.*", + "vcrpy == 7.*", +] } + +[project.urls] +Docs = "https://docs.easypost.com" +Tracker = "https://github.com/EasyPost/easypost-python/issues" +Source = "https://github.com/EasyPost/easypost-python" + +[tool.setuptools.packages.find] +exclude = ["docs", "examples", "tests"] + +[tool.setuptools.package-data] +easypost = ["py.typed"] + +[tool.black] +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/setup.py b/setup.py deleted file mode 100644 index 732e0b2..0000000 --- a/setup.py +++ /dev/null @@ -1,72 +0,0 @@ -from setuptools import ( - find_packages, - setup, -) - - -REQUIREMENTS = [ - "requests >= 2.4.3", -] - -DEV_REQUIREMENTS = [ - "bandit==1.8.*", - "black==25.*", - "build==1.2.*", - "flake8==6.*", - "isort==6.*", - "mypy==1.15.*", - "pdoc==15.*", - "pytest-cov==6.*", - "pytest-vcr==1.*", - "pytest==8.*", - "vcrpy==7.*", -] - -with open("README.md", encoding="utf-8") as f: - long_description = f.read() - -setup( - name="easypost", - version="10.3.0", - description="EasyPost Shipping API Client Library for Python", - author="EasyPost", - author_email="support@easypost.com", - url="https://easypost.com/", - packages=find_packages( - exclude=[ - "docs", - "examples", - "tests", - ] - ), - install_requires=REQUIREMENTS, - extras_require={ - "dev": DEV_REQUIREMENTS, - }, - package_data={ - "easypost": ["py.typed"], - }, - test_suite="test", - long_description=long_description, - long_description_content_type="text/markdown", - project_urls={ - "Docs": "https://docs.easypost.com", - "Tracker": "https://github.com/EasyPost/easypost-python/issues", - "Source": "https://github.com/EasyPost/easypost-python", - }, - python_requires=">=3.9, <4", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Programming Language :: Python", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Intended Audience :: Developers", - "Operating System :: OS Independent", - "License :: OSI Approved :: MIT License", - "Topic :: Software Development :: Libraries", - ], -) diff --git a/tests/conftest.py b/tests/conftest.py index 1e7d5be..4fb5dac 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,6 +8,7 @@ ) import pytest + from easypost.easypost_client import EasyPostClient diff --git a/tests/test_address.py b/tests/test_address.py index 346a930..ff2a71a 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_api_key.py b/tests/test_api_key.py index fa63fc2..07764d6 100644 --- a/tests/test_api_key.py +++ b/tests/test_api_key.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import ApiKey diff --git a/tests/test_base_service.py b/tests/test_base_service.py index 35770d8..766ba73 100644 --- a/tests/test_base_service.py +++ b/tests/test_base_service.py @@ -1,6 +1,7 @@ from unittest.mock import patch import pytest + from easypost.constant import NO_MORE_PAGES_ERROR from easypost.errors import EndOfPaginationError diff --git a/tests/test_batch.py b/tests/test_batch.py index c0d38b5..9e7ddee 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -3,6 +3,7 @@ import time import pytest + from easypost.models import Batch diff --git a/tests/test_beta_rate.py b/tests/test_beta_rate.py index 8c228fb..6d1e579 100644 --- a/tests/test_beta_rate.py +++ b/tests/test_beta_rate.py @@ -1,4 +1,5 @@ import pytest + from easypost.util import get_lowest_stateless_rate diff --git a/tests/test_beta_referral_customer.py b/tests/test_beta_referral_customer.py index fbeea44..4860ddf 100644 --- a/tests/test_beta_referral_customer.py +++ b/tests/test_beta_referral_customer.py @@ -1,4 +1,5 @@ import pytest + from easypost.errors.api.api_error import ApiError diff --git a/tests/test_billing.py b/tests/test_billing.py index fa6adcd..320dbb4 100644 --- a/tests/test_billing.py +++ b/tests/test_billing.py @@ -1,7 +1,8 @@ from unittest.mock import patch -import easypost import pytest + +import easypost from easypost.errors import InvalidObjectError diff --git a/tests/test_carrier_account.py b/tests/test_carrier_account.py index 5755439..edf6f97 100644 --- a/tests/test_carrier_account.py +++ b/tests/test_carrier_account.py @@ -1,4 +1,5 @@ import pytest + from easypost.errors.api.api_error import ApiError from easypost.models import CarrierAccount diff --git a/tests/test_claim.py b/tests/test_claim.py index 1cc38f3..7f47490 100644 --- a/tests/test_claim.py +++ b/tests/test_claim.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_customs_info.py b/tests/test_customs_info.py index 6a7cf92..34a49ca 100644 --- a/tests/test_customs_info.py +++ b/tests/test_customs_info.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import CustomsInfo diff --git a/tests/test_customs_item.py b/tests/test_customs_item.py index 15de173..2427394 100644 --- a/tests/test_customs_item.py +++ b/tests/test_customs_item.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import CustomsItem diff --git a/tests/test_easypost_client.py b/tests/test_easypost_client.py index 5609484..20721d8 100644 --- a/tests/test_easypost_client.py +++ b/tests/test_easypost_client.py @@ -3,6 +3,7 @@ import pytest import requests + from easypost.easypost_client import EasyPostClient from easypost.errors import TimeoutError diff --git a/tests/test_end_shipper.py b/tests/test_end_shipper.py index cd27936..8602810 100644 --- a/tests/test_end_shipper.py +++ b/tests/test_end_shipper.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import EndShipper diff --git a/tests/test_error.py b/tests/test_error.py index 99c5ebc..32c7784 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -1,4 +1,5 @@ import pytest + from easypost.errors.api.api_error import ApiError diff --git a/tests/test_event.py b/tests/test_event.py index 5abf7c7..d7f5eeb 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -3,6 +3,7 @@ import time import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_insurance.py b/tests/test_insurance.py index 98ca885..20f4b18 100644 --- a/tests/test_insurance.py +++ b/tests/test_insurance.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_order.py b/tests/test_order.py index 4e55617..a500b9c 100644 --- a/tests/test_order.py +++ b/tests/test_order.py @@ -1,4 +1,5 @@ import pytest + from easypost.errors import FilteringError from easypost.models import ( Order, diff --git a/tests/test_parcel.py b/tests/test_parcel.py index 0faee13..acfdb85 100644 --- a/tests/test_parcel.py +++ b/tests/test_parcel.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import Parcel diff --git a/tests/test_pickup.py b/tests/test_pickup.py index f142c4f..9a6d90b 100644 --- a/tests/test_pickup.py +++ b/tests/test_pickup.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_rate.py b/tests/test_rate.py index cf48246..993c9bd 100644 --- a/tests/test_rate.py +++ b/tests/test_rate.py @@ -1,4 +1,5 @@ import pytest + from easypost.models import Rate diff --git a/tests/test_referral_customer.py b/tests/test_referral_customer.py index 1930508..da4dbbd 100644 --- a/tests/test_referral_customer.py +++ b/tests/test_referral_customer.py @@ -2,6 +2,7 @@ from unittest.mock import patch import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_refund.py b/tests/test_refund.py index 359758e..16a751c 100644 --- a/tests/test_refund.py +++ b/tests/test_refund.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_report.py b/tests/test_report.py index 5aa61bd..cda07a2 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_scan_form.py b/tests/test_scan_form.py index 09e7509..2a87d72 100644 --- a/tests/test_scan_form.py +++ b/tests/test_scan_form.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_shipment.py b/tests/test_shipment.py index ec98ca6..3d55735 100644 --- a/tests/test_shipment.py +++ b/tests/test_shipment.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_tracker.py b/tests/test_tracker.py index afc71c0..2554feb 100644 --- a/tests/test_tracker.py +++ b/tests/test_tracker.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _FILTERS_KEY, _TEST_FAILED_INTENTIONALLY_ERROR, diff --git a/tests/test_user.py b/tests/test_user.py index d407764..deab7f4 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -1,4 +1,5 @@ import pytest + from easypost.constant import ( _TEST_FAILED_INTENTIONALLY_ERROR, NO_MORE_PAGES_ERROR, diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 021ae77..13c5e64 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -1,4 +1,5 @@ import pytest + from easypost.errors import SignatureVerificationError from easypost.models import Webhook from easypost.util import validate_webhook