Skip to content

Conversation

@stephenfin
Copy link
Contributor

This helper function uses printf-style formatting to print output, therefore it shouldn't be limited to strings: calling e.g.

format_values(['a', 'b', None])

is perfectly reasonable.

Signed-off-by: Stephen Finucane [email protected]

@stephenfin
Copy link
Contributor Author

stephenfin commented Apr 5, 2024

This popped up in github.com/click-contrib/sphinx-click. To the best of my knowledge, you can call str(foo) for any type of foo and it will print something, so Any object seems the best option.

@github-actions

This comment has been minimized.

stephenfin added a commit to click-contrib/sphinx-click that referenced this pull request Apr 5, 2024
There's one issue with these stubs - reported at [1] - that we ignore.
Otherwise, this is pretty simple.

[1] python/typeshed#11719

Signed-off-by: Stephen Finucane <[email protected]>
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks! But since – as you write – any value can be provided, confusingly object is the correct type, not Any. Any is the typing escape hatch, it basically means "we can't express this type using the current type system". While object means "we accept literally every possible value".

In this case, it makes no differences practically speaking, but we try to be correct here.

@stephenfin
Copy link
Contributor Author

Thanks! But since – as you write – any value can be provided, confusingly object is the correct type, not Any. Any is the typing escape hatch, it basically means "we can't express this type using the current type system". While object means "we accept literally every possible value".

In this case, it makes no differences practically speaking, but we try to be correct here.

TIL! Will update 🙂

This helper function uses printf-style formatting to print output,
therefore it shouldn't be limited to strings: calling e.g.

  format_values(['a', 'b', None])

is perfectly reasonable.

Signed-off-by: Stephen Finucane <[email protected]>
@stephenfin stephenfin force-pushed the docutils-format_values branch from 5726c48 to c466079 Compare April 5, 2024 16:36
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 7119589 into python:main Apr 5, 2024
@stephenfin stephenfin deleted the docutils-format_values branch April 5, 2024 18:42
stephenfin added a commit to click-contrib/sphinx-click that referenced this pull request May 14, 2024
[1] was merged.

[1] python/typeshed#11719

Signed-off-by: Stephen Finucane <[email protected]>
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.

2 participants