Skip to content

Conversation

@derekhiggins
Copy link
Contributor

@derekhiggins derekhiggins commented Nov 26, 2025

fix: use string annotations for S3Client type hints

Remove future annotations import and use quoted string annotations for S3Client to avoid import issues.

Changes:
o Remove __future__ annotations import
o Use "S3Client" string annotations in type hints

closes: #4241

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 26, 2025
Copy link
Collaborator

@mattf mattf left a comment

Choose a reason for hiding this comment

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

we should avoid eval_str=True

s3/files.py uses future annotations while localfs/files.py does not.

do we need import __future__ import annotations for the s3 provider?

@derekhiggins
Copy link
Contributor Author

we should avoid eval_str=True

s3/files.py uses future annotations while localfs/files.py does not.

do we need import __future__ import annotations for the s3 provider?

It seems like the import is there to allow mypy_boto3_s3 to be a dependency only when doing
type checking but not be a runtime dependency,

There are 2 alternative I can think of

  1. Remove __future__ import, use quoted strings (e.g. https://gist.github.com/derekhiggins/57e951803d42a6dab60c34521d1f2c53 )

  2. Add mypy_boto3_s3 as a run time dependency of the s3 provider, which will allow us to remove the TYPE_CHECKING check and the futures import

@mattf
Copy link
Collaborator

mattf commented Dec 1, 2025

we should avoid eval_str=True
s3/files.py uses future annotations while localfs/files.py does not.
do we need import __future__ import annotations for the s3 provider?

It seems like the import is there to allow mypy_boto3_s3 to be a dependency only when doing type checking but not be a runtime dependency,

There are 2 alternative I can think of

1. Remove `__future__` import, use quoted strings (e.g. https://gist.github.com/derekhiggins/57e951803d42a6dab60c34521d1f2c53 )

2. Add mypy_boto3_s3 as a run time dependency of the s3 provider, which will allow us to remove the `TYPE_CHECKING` check and the **futures** import

i'm good with (1) if you are

Remove future annotations import and use quoted string annotations for S3Client to avoid import issues.

Changes:
o Remove __future__ annotations import
o Use "S3Client" string annotations in type hints

Signed-off-by: Derek Higgins <[email protected]>
@derekhiggins
Copy link
Contributor Author

i'm good with (1) if you are

works for me, PR updated, thanks

Copy link
Collaborator

@mattf mattf left a comment

Choose a reason for hiding this comment

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

lgtm

@derekhiggins derekhiggins changed the title fix(files): Evaluate string annotations fix: use string annotations for S3Client type hints Dec 1, 2025
Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

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

lg

@ashwinb ashwinb merged commit 9616448 into llamastack:main Dec 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't upload files to s3 provider

4 participants