Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

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

Merged
bblommers merged 1 commit into
mainfrom
chore-typing-more-utils
Mar 6, 2026
Merged

bblommers merged 1 commit into
mainfrom
chore-typing-more-utils

Conversation

@bblommers

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

github-actions Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

Test Results - Preflight, Unit

23 104 tests  ±0   21 217 ✅ ±0   6m 18s ⏱️ ±0s
     1 suites ±0    1 887 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 85cfbe3. ± Comparison against base commit 9642b8e.

♻️ This comment has been updated with latest results.

@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

github-actions Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

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

Results for commit 85cfbe3. ± Comparison against base commit 9642b8e.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 41m 9s ⏱️
5 760 tests 5 233 ✅ 527 💤 0 ❌
5 766 runs  5 233 ✅ 533 💤 0 ❌

Results for commit 85cfbe3.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Feb 2, 2026 •

Copy link
Copy Markdown

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   2h 3m 26s ⏱️ - 1m 22s
5 355 tests ±0  4 984 ✅ ±0  371 💤 ±0  0 ❌ ±0 
5 357 runs  ±0  4 984 ✅ ±0  373 💤 ±0  0 ❌ ±0 

Results for commit 85cfbe3. ± Comparison against base commit 9642b8e.

♻️ This comment has been updated with latest results.

@bblommers
bblommers marked this pull request as ready for review February 2, 2026 13:00
@alexrashed

Copy link
Copy Markdown
Member

@dfangl @dominikschubert Seems like this PR slipped through and is just waiting for a review?

@alexrashed alexrashed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Jumping in here instead of @dfangl and @dominikschubert to get this in.
The changes are looking good, thanks for the additional context on the changes which are not only typing changes (but they are all looking good)! The more typing the better! 💯

@bblommers
bblommers force-pushed the chore-typing-more-utils branch from 45a1bae to 85cfbe3 Compare March 6, 2026 10:48
@bblommers
bblommers merged commit 1c66dc0 into main Mar 6, 2026
35 checks passed
@bblommers
bblommers deleted the chore-typing-more-utils branch March 6, 2026 12:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

2 participants