Skip to content

Commit

Permalink
Merge branch 'release-0.10.3'
Browse files Browse the repository at this point in the history
* release-0.10.3:
  Bumping version to 0.10.3
  Add support for Python 3.13 (#315)
  Update setuptools (#313)
  Temporary fix for setuptools 70.x (#311)
  Updating contributing guide
  Add I for isort functionality
  Add unsafe changes
  Run ruff over codebase
  Add ruff setup
  • Loading branch information
aws-sdk-python-automation committed Oct 8, 2024
2 parents 9a16829 + bf87770 commit 7878fbf
Show file tree
Hide file tree
Showing 54 changed files with 221 additions and 199 deletions.
7 changes: 7 additions & 0 deletions .changes/0.10.3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"category": "Python",
"description": "Added provisional Python 3.13 support to s3transfer",
"type": "enhancement"
}
]
4 changes: 3 additions & 1 deletion .github/workflows/run-crt-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macOS-latest, windows-latest]
# Python 3.8 and 3.9 do not run on m1 hardware which is now standard for
# macOS-latest.
Expand All @@ -30,6 +30,8 @@ jobs:
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
allow-prereleases: true
- name: Install dependencies and CRT
run: |
python scripts/ci/install --extras crt
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macOS-latest, windows-latest]
# Python 3.8 and 3.9 do not run on m1 hardware which is now standard for
# macOS-latest.
Expand All @@ -33,6 +33,8 @@ jobs:
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
allow-prereleases: true
- name: Install dependencies
run: |
python scripts/ci/install
Expand Down
26 changes: 5 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,9 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: 'https://github.com/asottile/pyupgrade'
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: pyupgrade
args:
- '--py37-plus'
- repo: 'https://github.com/PyCQA/isort'
rev: 5.12.0
hooks:
- id: isort
- repo: 'https://github.com/psf/black'
rev: 23.11.0
hooks:
- id: black
- repo: 'https://github.com/pycqa/flake8'
rev: 6.1.0
hooks:
- id: flake8
- repo: 'https://github.com/codespell-project/codespell'
rev: v2.1.0
hooks:
- id: codespell
- id: ruff
args: [ --fix ]
- id: ruff-format
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
=========

0.10.3
======

* enhancement:Python: Added provisional Python 3.13 support to s3transfer


0.10.2
======

Expand Down
18 changes: 8 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ ideal report includes:

Codestyle
---------
This project uses flake8 to enforce codstyle requirements. We've codified this
process using a tool called `pre-commit <https://pre-commit.com/>`__. pre-commit
allows us to specify a config file with all tools required for code linting,
and surfaces either a git commit hook, or single command, for enforcing these.
This project uses `ruff <https://github.com/astral-sh/ruff>`__ to enforce
codstyle requirements. We've codified this process using a tool called
`pre-commit <https://pre-commit.com/>`__. pre-commit allows us to specify a
config file with all tools required for code linting, and surfaces either a
git commit hook, or single command, for enforcing these.

To validate your PR prior to publishing, you can use the following
`installation guide <https://pre-commit.com/#install>`__ to setup pre-commit.
Expand All @@ -51,10 +52,7 @@ to automatically perform the codestyle validation:
$ pre-commit run
This will automatically perform simple updates (such as white space clean up)
and provide a list of any failing flake8 checks. After these are addressed,
and provide a list of any failing checks. After these are addressed,
you can commit the changes prior to publishing the PR.
These checks are also included in our CI setup under the "Lint" workflow which will provide output on Github for anything missed locally.

See the `flake8` section of the
`setup.cfg <https://github.com/boto/s3transfer/blob/develop/setup.cfg>`__ for the
currently enforced rules.
These checks are also included in our CI setup under the "Lint" workflow which
will provide output on Github for anything missed locally.
65 changes: 58 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,63 @@ markers = [
"slow: marks tests as slow",
]

[tool.isort]
profile = "black"
line_length = 79
honor_noqa = true
src_paths = ["s3transfer", "tests"]
[tool.ruff]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

[tool.black]
# Format same as Black.
line-length = 79
skip_string_normalization = true
indent-width = 4

target-version = "py38"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "I", "UP"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings, spaces for indents
# and trailing commas.
quote-style = "preserve"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

docstring-code-format = false
docstring-code-line-length = "dynamic"
34 changes: 15 additions & 19 deletions requirements-dev-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
atomicwrites==1.4.1 \
--hash=sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11
# via -r requirements-dev.txt
colorama==0.4.5 \
--hash=sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da \
--hash=sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via -r requirements-dev.txt
coverage[toml]==7.2.7 \
--hash=sha256:06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f \
Expand Down Expand Up @@ -75,21 +75,21 @@ coverage[toml]==7.2.7 \
# via
# -r requirements-dev.txt
# pytest-cov
exceptiongroup==1.1.3 \
--hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \
--hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3
exceptiongroup==1.2.2 \
--hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \
--hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc
# via pytest
iniconfig==1.1.1 \
--hash=sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3 \
--hash=sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32
iniconfig==2.0.0 \
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
# via pytest
packaging==21.3 \
--hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \
--hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522
packaging==24.1 \
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
# via pytest
pluggy==1.4.0 \
--hash=sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981 \
--hash=sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be
pluggy==1.5.0 \
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
# via pytest
psutil==4.4.2 \
--hash=sha256:10fbb631142a3200623f4ab49f8bf82c32b79b8fe179f6056d01da3dfc589da1 \
Expand All @@ -102,10 +102,6 @@ psutil==4.4.2 \
--hash=sha256:e423dd9cb12256c742d1d56ec38bc7d2a7fa09287c82c41e475e68b9f932c2af \
--hash=sha256:e44d6b758a96539e3e02336430d3f85263d43c470c5bad93572e9b6a86c67f76
# via -r requirements-dev.txt
pyparsing==3.0.9 \
--hash=sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb \
--hash=sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc
# via packaging
pytest==8.1.1 \
--hash=sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7 \
--hash=sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ psutil>=4.1.0,<5.0.0
tabulate==0.7.5
coverage==7.2.7
wheel==0.43.0
setuptools==67.8.0;python_version>="3.12"
setuptools==71.1.0;python_version>="3.12"
packaging==24.1;python_version>="3.12" # Requirement for setuptools>=71

# Pytest specific deps
pytest==8.1.1
Expand Down
7 changes: 4 additions & 3 deletions s3transfer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def __call__(self, bytes_amount):
"""

import concurrent.futures
import functools
import logging
Expand All @@ -144,7 +145,7 @@ def __call__(self, bytes_amount):
from s3transfer.exceptions import RetriesExceededError, S3UploadFailedError

__author__ = 'Amazon Web Services'
__version__ = '0.10.2'
__version__ = '0.10.3'


class NullHandler(logging.Handler):
Expand Down Expand Up @@ -813,8 +814,8 @@ def _validate_all_known_args(self, actual, allowed):
for kwarg in actual:
if kwarg not in allowed:
raise ValueError(
"Invalid extra_args key '%s', "
"must be one of: %s" % (kwarg, ', '.join(allowed))
f"Invalid extra_args key '{kwarg}', "
f"must be one of: {', '.join(allowed)}"
)

def _ranged_download(
Expand Down
4 changes: 1 addition & 3 deletions s3transfer/bandwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def __init__(self, requested_amt, retry_time):
"""
self.requested_amt = requested_amt
self.retry_time = retry_time
msg = 'Request amount {} exceeded the amount available. Retry in {}'.format(
requested_amt, retry_time
)
msg = f'Request amount {requested_amt} exceeded the amount available. Retry in {retry_time}'
super().__init__(msg)


Expand Down
4 changes: 2 additions & 2 deletions s3transfer/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
'ExpectedBucketOwner',
]

USER_AGENT = 's3transfer/%s' % s3transfer.__version__
PROCESS_USER_AGENT = '%s processpool' % USER_AGENT
USER_AGENT = f's3transfer/{s3transfer.__version__}'
PROCESS_USER_AGENT = f'{USER_AGENT} processpool'
2 changes: 1 addition & 1 deletion s3transfer/copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _get_head_object_request_from_copy_source(self, copy_source):
raise TypeError(
'Expecting dictionary formatted: '
'{"Bucket": bucket_name, "Key": key} '
'but got %s or type %s.' % (copy_source, type(copy_source))
f'but got {copy_source} or type {type(copy_source)}.'
)

def _extra_upload_part_args(self, extra_args):
Expand Down
4 changes: 1 addition & 3 deletions s3transfer/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ def _get_download_output_manager_cls(self, transfer_future, osutil):
if download_manager_cls.is_compatible(fileobj, osutil):
return download_manager_cls
raise RuntimeError(
'Output {} of type: {} is not supported.'.format(
fileobj, type(fileobj)
)
f'Output {fileobj} of type: {type(fileobj)} is not supported.'
)

def _submit(
Expand Down
14 changes: 5 additions & 9 deletions s3transfer/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ def __init__(self, transfer_id=None):
self._failure_cleanups_lock = threading.Lock()

def __repr__(self):
return '{}(transfer_id={})'.format(
self.__class__.__name__, self.transfer_id
)
return f'{self.__class__.__name__}(transfer_id={self.transfer_id})'

@property
def exception(self):
Expand Down Expand Up @@ -295,8 +293,8 @@ def _transition_to_non_done_state(self, desired_state):
with self._lock:
if self.done():
raise RuntimeError(
'Unable to transition from done state %s to non-done '
'state %s.' % (self.status, desired_state)
f'Unable to transition from done state {self.status} to non-done '
f'state {desired_state}.'
)
self._status = desired_state

Expand All @@ -316,9 +314,7 @@ def submit(self, executor, task, tag=None):
:returns: A future representing the submitted task
"""
logger.debug(
"Submitting task {} to executor {} for transfer request: {}.".format(
task, executor, self.transfer_id
)
f"Submitting task {task} to executor {executor} for transfer request: {self.transfer_id}."
)
future = executor.submit(task, tag=tag)
# Add this created future to the list of associated future just
Expand Down Expand Up @@ -400,7 +396,7 @@ def _run_callback(self, callback):
# We do not want a callback interrupting the process, especially
# in the failure cleanups. So log and catch, the exception.
except Exception:
logger.debug("Exception raised in %s." % callback, exc_info=True)
logger.debug(f"Exception raised in {callback}.", exc_info=True)


class BoundedExecutor:
Expand Down
12 changes: 6 additions & 6 deletions s3transfer/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def _validate_attrs_are_nonzero(self):
for attr, attr_val in self.__dict__.items():
if attr_val is not None and attr_val <= 0:
raise ValueError(
'Provided parameter %s of value %s must be greater than '
'0.' % (attr, attr_val)
f'Provided parameter {attr} of value {attr_val} must '
'be greater than 0.'
)


Expand Down Expand Up @@ -492,16 +492,16 @@ def _validate_if_bucket_supported(self, bucket):
match = pattern.match(bucket)
if match:
raise ValueError(
'TransferManager methods do not support %s '
'resource. Use direct client calls instead.' % resource
f'TransferManager methods do not support {resource} '
'resource. Use direct client calls instead.'
)

def _validate_all_known_args(self, actual, allowed):
for kwarg in actual:
if kwarg not in allowed:
raise ValueError(
"Invalid extra_args key '%s', "
"must be one of: %s" % (kwarg, ', '.join(allowed))
"Invalid extra_args key '{}', "
"must be one of: {}".format(kwarg, ', '.join(allowed))
)

def _add_operation_defaults(self, bucket, extra_args):
Expand Down
Loading

0 comments on commit 7878fbf

Please sign in to comment.