On Tue, 11 Jun 2019 at 10:38, Jakub Stasiak <jakub@stasiak.at> wrote:


> On 2 Jun 2019, at 02:29, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
>
> On Tue, 28 May 2019 at 16:58, Till <till.varoquaux@gmail.com> wrote:
> Thanks Jakub,
> You're right __origin__ should point to `Annotated`. I created a pull
> request (https://github.com/python/typing/pull/635) that should
> address that.
>
> I actually don't agree with this change. __origin__ is not a public API and we should not make internal implementation
> (much) more complex to simplify any public use of it. This is precisely the case why `get_origin()` and `get_args()` were just added
> to `typing` -- to "decouple" private and public introspection APIs.
>
> Moreover, I think _AnnotatedAlias is much more similar to _GenericAlias than to special forms like ClassVar, so it makes sense
> to make it a "thin" subclass of the latter. `get_origin()` and `get_args()` can be adjusted to return `Annotated` and `(int, 'some marker')`.
>

I imagine it’s too late to change the functions’ names? I believe something like get_generic_type instead of get_origin and get_generic_args instead of get_args would be *slightly* easier to understand for newcomers.

Thanks for the idea, but yes, it is technically too late. Second, the exsiting names are already familiar for people who worked with runtime inspection of typing types.
Finally, I don't think `get_generic_type(List[int])` returning `list` is totally intuitive. So after all I would leave the names alone.

--
Ivan