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

Main api #53

Merged
merged 4 commits into from
Sep 30, 2024
Merged

Main api #53

merged 4 commits into from
Sep 30, 2024

Conversation

toabctl
Copy link
Member

@toabctl toabctl commented Sep 27, 2024

No description provided.

Instead of having logic in the cli module, have a proper api module
that is exposed directory on the awspub module level. That way, the
api can be used simply with:

> import awspub
> awspub.create()
> awspub.public()

and so on.
@toabctl
Copy link
Member Author

toabctl commented Sep 27, 2024

This is actually only moving code from cli/init.py to the new api.py . and then increase test coverage and add documentation. and obviously use the api from the cli module.

rpocase
rpocase previously approved these changes Sep 27, 2024
Copy link
Collaborator

@rpocase rpocase left a comment

Choose a reason for hiding this comment

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

overall lgtm. couple nits

awspub/api.py Outdated Show resolved Hide resolved
docs/reference/logic.rst Outdated Show resolved Hide resolved
JessicaJang
JessicaJang previously approved these changes Sep 27, 2024
@toabctl toabctl dismissed stale reviews from JessicaJang and rpocase via bb78a23 September 30, 2024 06:58
With that, it's easier to understand which API should actually be used
when integrating the awspub python module.
To increase test coverage and make sure that no regression will be
introduced.
Use an actionable name for the publication step to make the action
more obvious.
Copy link

@gjolly gjolly left a comment

Choose a reason for hiding this comment

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

mypy strict gives me:

awspub/api.py:114: error: Function is missing a return type annotation  [no-untyped-def]
awspub/api.py:131: error: Function is missing a return type annotation  [no-untyped-def]
awspub/api.py:148: error: Missing type parameters for generic type "Dict"  [type-arg]
awspub/api.py:161: error: Missing type parameters for generic type "Dict"  [type-arg]
Found 4 errors in 1 file (checked 1 source file)

But you haven't configured mypy with --strict in tox.ini so I don't know if you want to fix that.


def _images_grouped(
images: List[Tuple[str, Image, Dict[str, _ImageInfo]]], group: Optional[str]
) -> Tuple[Dict[str, Dict[str, str]], Dict[str, Dict[str, Dict[str, str]]]]:
Copy link

Choose a reason for hiding this comment

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

You could define your custom types here. Like:

type ImageMetadata = Dict[str, str]

Copy link
Member Author

Choose a reason for hiding this comment

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

type is >= python 3.12 (see https://docs.python.org/3/reference/simple_stmts.html#type ). but we want to support 3.10 (from jammy) for now.

:param group: a optional group name
:type group: Optional[str]
:return: the images grouped by name and by group
:rtype: Tuple[Dict[str, Dict[str, str]], Dict[str, Dict[str, Dict[str, str]]]
Copy link

Choose a reason for hiding this comment

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

Why is this needed, it's already in the signature above.

Copy link
Member Author

Choose a reason for hiding this comment

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

looks like there is https://github.com/tox-dev/sphinx-autodoc-typehints that might help here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filled #56 to explore this more.

@toabctl
Copy link
Member Author

toabctl commented Sep 30, 2024

mypy strict gives me:

awspub/api.py:114: error: Function is missing a return type annotation  [no-untyped-def]
awspub/api.py:131: error: Function is missing a return type annotation  [no-untyped-def]
awspub/api.py:148: error: Missing type parameters for generic type "Dict"  [type-arg]
awspub/api.py:161: error: Missing type parameters for generic type "Dict"  [type-arg]
Found 4 errors in 1 file (checked 1 source file)

But you haven't configured mypy with --strict in tox.ini so I don't know if you want to fix that.

Created #55 to enable strict mode.

@toabctl toabctl merged commit b75390d into canonical:main Sep 30, 2024
6 checks passed
@toabctl toabctl deleted the main-api branch September 30, 2024 14:40
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.

4 participants