Skip to content

Chore: More typing for utils/Files and utils/DockerUtils#13677

Open
bblommers wants to merge 1 commit intomainfrom
chore-typing-more-utils
Open

Chore: More typing for utils/Files and utils/DockerUtils#13677
bblommers wants to merge 1 commit intomainfrom
chore-typing-more-utils

Conversation

@bblommers
Copy link
Contributor

Motivation

This PR adds/corrects some more type hints, primarily to the utils/files.py and any related utilities. The mypy configuration was also updated to now verify that these hints are correct.

Changes

Most of the changes are straightforward - I'll add some inline comments if it may not be immediately obvious.

Tests

There should not be any logical changes - but I did run the upstream tests against this branch just in case, and everything passed.

Related

#13658

@bblommers bblommers added this to the Playground milestone Feb 2, 2026
@bblommers bblommers added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Feb 2, 2026

if os.path.exists(file_or_str):
file_or_str = load_file(file_or_str)
file_or_str = load_file(file_or_str) # type: ignore[assignment]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

load_file can return None if the file does not exist. Either the load_file method should be more stringent in what it returns, or we should explicitly verify here that load_file returns something useful.

Either way - I didn't want to change the logic in any way, that's why I just added the type: ignore

if is_debian():
try:
return run(f'rm -rf "{path}"')
return run(f'rm -rf "{path}"') # type: ignore[return-value]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the callers of this method seem to actually use the return-type, so I think it would be safe to change this to:

run(f'rm -rf "{path}"')
return

But again - I didn't want to change the logic and break things, hence the type: ignore

Comment on lines -255 to -256
if "dirs_exist_ok" in inspect.getfullargspec(shutil.copytree).args:
kwargs["dirs_exist_ok"] = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dirs_exist_ok argument was added in Python 3.8, so I think we're OK to always pass the argument.

Docs: https://docs.python.org/3/library/shutil.html#shutil.copytree

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results - Preflight, Unit

23 088 tests   21 229 ✅  6m 23s ⏱️
     1 suites   1 859 💤
     1 files         0 ❌

Results for commit 45a1baef.

@bblommers bblommers changed the title Chore: More typing for Files utils Chore: More typing for utils/Files and utils/DockerUtils Feb 2, 2026
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results (amd64) - Acceptance

7 tests   5 ✅  3m 0s ⏱️
1 suites  2 💤
1 files    0 ❌

Results for commit 45a1baef.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 34m 27s ⏱️
5 599 tests 5 041 ✅ 558 💤 0 ❌
5 605 runs  5 041 ✅ 564 💤 0 ❌

Results for commit 45a1baef.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

LocalStack Community integration with Pro

    2 files      2 suites   1h 57m 7s ⏱️
5 178 tests 4 790 ✅ 388 💤 0 ❌
5 180 runs  4 790 ✅ 390 💤 0 ❌

Results for commit 45a1baef.

@bblommers bblommers marked this pull request as ready for review February 2, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant