Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run pre-commit on s3transfer #9385

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open

run pre-commit on s3transfer #9385

wants to merge 1 commit into from

Conversation

kdaily
Copy link
Member

@kdaily kdaily commented Mar 18, 2025

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aemous aemous self-requested a review March 20, 2025 20:32
Copy link
Contributor

@aemous aemous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple small requested changes.

One overarching concern I have is, will some of these cause us to deviate from boto/s3transfer? Do we want to match our formatting options to be identical to the ones used in that repo? For whitespaces it may not be a big deal, but for reordering imports and swapping interchangeable exceptions I wonder if this becomes a concern

@@ -56,7 +57,7 @@ def test_non_file_like_obj(self):
def test_non_seekable_ioerror(self):
Copy link
Contributor

@aemous aemous Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to test_non_seekable_oserror since we're switching to raise OSError here

non-blocking.

@@ -329,7 +329,7 @@ def test_allocate(self):

@mock.patch('s3transfer.utils.fallocate')
def test_allocate_with_io_error(self, mock_fallocate):
mock_fallocate.side_effect = IOError()
mock_fallocate.side_effect = OSError()
with self.assertRaises(IOError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be worth (and safe) swapping this IoError for oserror too. And also renaming to reflect this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure; raising an IOError or OSError result in identical behavior.

>>> try:
...     raise OSError
... except IOError:
...     print("hooray")
...
...
hooray
>>> try:
...     raise IOError
... except OSError:
...     print("hooray")
...
...
hooray

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I just figured if we're replacing the deprecated IOError in line 332, that we may as well also do a similar swap on 333.

I understand they're functionally equivalent.

Also non-blocking, feel free to resolve if you disagree

@kdaily
Copy link
Member Author

kdaily commented Mar 20, 2025

Regarding socket.error to OSError:

https://docs.astral.sh/ruff/rules/os-error-alias/

Also, just to check its really an alias (confirmed this back to Python 3.8):

>>> import socket
>>> raise socket.error
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    raise socket.error
OSError

@kdaily kdaily requested a review from aemous March 20, 2025 22:22
@kdaily
Copy link
Member Author

kdaily commented Mar 20, 2025

will some of these cause us to deviate from boto/s3transfer

In the short term, yes, only because we enabled Ruff to do the import sorting (instead of isort). Offline discussions resulted in us going ahead with the more modern approach and the boto repositories (botocore and s3transfer) will catch up. For botocore, there is already a customer PR to modernize import sorting:

boto/botocore#3380

See discussion when enabling ruff import sorting on the CLI repository here:

@kdaily kdaily force-pushed the lint-format-s3transfer branch from f025b4a to b98f13d Compare March 20, 2025 22:30
@kdaily
Copy link
Member Author

kdaily commented Mar 20, 2025

Force-pushed to pull in latest v2 changes, required for running internal build.

Copy link
Contributor

@aemous aemous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have a couple non-blocking unresolved comments if you agree with them, otherwise I'm good with merging this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants