# PEPs
* [PEP 612 — Parameter Specification Variables](https://peps.python.org/pep-0612/) — [[#PEP-612 Parameter Specification Variables|Notes]]
* [PEP 647 — Type Guards](https://peps.python.org/pep-0647/) — [[#PEP-647 Type Guards|Notes]]
## Notes
### PEP-612: Parameter Specification Variables
* [PEP 612](https://peps.python.org/pep-0612/)
* Introduces `ParamSpec`, `Concatenate`
* Cannot be used to mirror another function's signature without some decorator madness
* Related discussions:
* [Proposal: signature copying for kwargs](https://github.com/python/typing/issues/270)
* Several pieces of discussion, but a main thread is people wanting `function1` to be able to inherit `**kwargs` from `function2`.
### PEP-647: Type Guards
* [PEP 647](https://peps.python.org/pep-0647/)
* Can only narrow in the positive case, not the negative case
```python
MyType: TypeAlias = Union[Type1, Type2]
def is_type1(value: MyType) -> TypeGuard[Type1]:
return True # Or whatever condition
value: MyType = ...
if is_type1(value):
# value is narrowed to Type1
...
else:
# value is still Union[Type1, Type2]
...
```
# General Typing Notes
## Invariance in Lists/Dicts
`List` vs. `Sequence` can be very important.
If the list isn't going to be modified (can be treated as read-only), be sure to use `Sequence` and not `List`.
This applies to `Dict` vs. `Mapping` as well.