# PEP 695: Type Parameter Syntax

**URL:** <https://discuss.python.org/t/pep-695-type-parameter-syntax/21646>\
**Category:** PEPs\
**Created:** [December 4, 2022, 5:13pm UTC](https://discuss.python.org/t/pep-695-type-parameter-syntax/21646 "2022-12-04T17:13:26Z")\
**Posts on this page:** 1\
**Showing post:** 68

<div class="post-metadata">

**Author:** ![ntessore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ntessore/32/10786_2.png) [@ntessore](https://discuss.python.org/u/ntessore)\
**Post date:** [March 29, 2023, 1:25pm UTC](https://discuss.python.org/t/pep-695-type-parameter-syntax/21646/68 "2023-03-29T13:25:54Z")

</div>

> [@brettcannon](#):
>
> That won’t work (literally) because decorators don’t introduce names, so referencing those type hints later would lead to a `NameError`. Basically you would have to update the parser to special-case your `@generic` and that isn’t acceptable in my opinion.

> [@tmk](#):
>
> > We likewise considered prefix forms that looked like decorators (e.g., `@using(S, T)`). This idea was rejected because such forms would be confused with regular decorators, and they would not compose well with existing decorators. Furthermore, decorators are logically executed after the statement they are decorating, so it would be confusing for them to introduce symbols (type parameters) that are visible within the “decorated” statement, which is logically executed before the decorator itself.

Both of these issues are not insurmountable:

```py
from typing import TypeVar

def generic(*typespec):
    unset = object()
    glbls = globals()
    store = {t. __name__ : glbls.get(t. __name__ , unset) for t in typespec}
    for t in typespec:
        glbls[t. __name__] = t
    def decorator(function):
        for name, value in store.items():
            if value is unset:
                del glbls[name]
            else:
                glbls[name] = value
        return function
    return decorator

@generic(TypeVar('T'))
def myfunction(x: T):
    ...

```

With the ` __coannotations__ ` magic, that would probably not even have to touch global scope.

Of course we haven’t really won anything by still needing to write out the `TypeVar('T')` here, so this is really only addressing the points made above.

---

_[View the full topic](https://discuss.python.org/t/pep-695-type-parameter-syntax/21646)._
