On 2021-12-13 17:07, Steven D'Aprano wrote:
>As an aside, seeing what the docs say about Annotated makes me think
>that "Annotated" is a very bad name for this thing. It confuses the
>idea of a type annotation (i.e., attached to a variable) with this
>type-incorporating-a-label, where neithe
If we proceed with using `Annotated`, I suggest it be the last string
in the metadata. Using your example:
spam: Annotated[
int,
Positive,
GreaterThan[1],
"Doc string goes here..."
Union[Odd|Literal[2]],
Prime,
Wibble,
Wobble,
] = 2
In other words, strings would be reserved to spe
On Sun, Dec 12, 2021 at 07:43:16PM -0800, Brendan Barnwell wrote:
> The question is what does this annotate:
>
> Annotated[int, "some text here"]
Nothing. There's no annotation there.
That's an expression which returns a type alias. It is just an object.
You can print it, put it in a lis
Thinking more about my example here:
On Tue, Dec 14, 2021 at 01:50:45AM +1100, Steven D'Aprano wrote:
> class MyClass:
> """Blah blah blah.
>
> Variable annotations of the form Annotated[T, 'string', *args]
> always interpret the string in the second position as a
>
FYI: The flake8 project refuses to add toml configuration file support in
part because there is no standard library toml
module: https://github.com/PyCQA/flake8/issues/234#issuecomment-812800722
The thread was eventually locked by the project owner, and a project sprang
up to try to address the
I've been holding off commenting on this because frankly y'all talk a hell
of a lot and I'm still about five days back trying to keep up with all the
back-and-forth. So probably some of this repeats something that's been said
and I apologize for that, but I did want to put my two cents' worth in.
On Mon, Dec 13, 2021 at 6:54 AM Steven D'Aprano wrote:
>
> Okay, I'm sorry, I understand the statement to be referring to people
> who had no intention of using type-hints. For those people,
> no_type_hints is the right solution. But for those who want type hints
> as well as docstrings, it is no
On Mon, Dec 13, 2021 at 7:14 AM Simão Afonso <
simao.afo...@powertools-tech.com> wrote:
> What about having a docstring but no typing information? In this case
> that's impossible, no?
spam: Annotated[Any, 'Yummy meat-like product']
or
spam: Annotated[None, 'Yummy meat-like product']
-CHB
___
Steven D'Aprano writes:
> On Sun, Dec 12, 2021 at 08:44:25PM -0500, Ricky Teachey wrote:
> > class C:
> > x: Annotated [Any, "spam"]
> >
> > help(C.x)
>
> > And it seems reasonable to try and create a way for it to work.
>
> By default, for arbitrary classes, no, it *shouldn't* wor
On 2021-12-14 01:50:45, Steven D'Aprano wrote:
> On Sun, Dec 12, 2021 at 12:23:54PM -0800, Christopher Barker wrote:
> > And I note that Annotated flattens nested Annotated types, so having both a
> > docstring and other use of Annotated could be a bit tricky.
>
> class MyClass:
> """B
On Sun, Dec 12, 2021 at 12:23:54PM -0800, Christopher Barker wrote:
> > the tools will follow. Runtime tools will
> > look at the dunder, static tools will look at the annotation directly.
> >
>
> I hope not. *maybe* inspect.get_annotations() though.
Sorry, I don't understand your position here.
On Sun, Dec 12, 2021 at 05:34:33PM -0800, Paul Bryan wrote:
> 1. While I agree that assigning the `Annotated` value to `SomeType`
> makes `SomeType` a type alias, what do you call the specific instance
> of `Annotated[...]` itself?
Its a type. The specific type is a private implementation detail:
12 matches
Mail list logo