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

Add a clip_to_source kwarg to subscript_request.build_request #971

Merged
merged 9 commits into from
Jul 7, 2023

Conversation

sgillies
Copy link
Contributor

@sgillies sgillies commented Jun 30, 2023

This could be a preview of the behavior of the next API version.

Resolves #967

This is a preview of the behavior of the next API version.
@click.option(
'--tools',
type=types.JSON(),
help='Toolchain JSON. Can be a string, filename, or - for stdin.')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is all on yapf and not explained by anything in its change log 😒

Copy link
Contributor Author

@sgillies sgillies Jul 3, 2023

Choose a reason for hiding this comment

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

And it's version dependent. With Python 3.7, yapf 0.40.1 puts '--tools' on line 208. WTH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're now using Python 3.8 for the CI linting checks.

exists. NOTE: the next version of the Subscription API will
remove the clip tool option and always clip to the source
geometry. Thus this is a preview of the next API version's
default behavior.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this above the example.

delivery: dict,
notifications: Optional[dict] = None,
tools: Optional[List[dict]] = None) -> dict:
source: Mapping,
Copy link
Contributor Author

@sgillies sgillies Jun 30, 2023

Choose a reason for hiding this comment

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

Typing best practices (https://typing.readthedocs.io/en/latest/source/best_practices.html) is to accept mappings (most general) and return dicts (most specific). This follows Postel's Law.

"""
details = {"name": name, "source": source, "delivery": delivery}
details = {
"name": name, "source": dict(source), "delivery": dict(delivery)
Copy link
Contributor Author

@sgillies sgillies Jun 30, 2023

Choose a reason for hiding this comment

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

Here is the consequence of accepting mappings: we need to explicitly convert them to dicts here. The upside is that we will never modify dicts that users pass in to this function, which can cause subtle bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We copy information now, which has some overhead, but makes calling code more reliable. And building a subscriptions request doesn't need to be super optimized.

@sgillies sgillies added this to the 2.1.0 milestone Jul 3, 2023
@sgillies sgillies marked this pull request as ready for review July 6, 2023 18:08
Also temporarily pin click to < 8.1.4
@sgillies sgillies merged commit 79d9a3c into main Jul 7, 2023
9 checks passed
@sgillies sgillies deleted the issue967 branch July 7, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reuse subscription source geometry in clip tool
1 participant