mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Updated library guidance to include a small section on positional-only parameters.
This commit is contained in:
parent
2633780c6d
commit
2c7bcc81e1
@ -252,6 +252,17 @@ def create_user(age: int, *, dob: Optional[date] = None):
|
||||
...
|
||||
```
|
||||
|
||||
### Positional-only Parameters
|
||||
If a function or method is intended to take parameters that are specified only by position, use the positional-only separator ("/") as documented in [PEP 570](https://peps.python.org/pep-0570/). If your library needs to run on versions of Python prior to 3.8, you can alternatively name the positional-only parameters with an identifier that begins with a double underscore.
|
||||
|
||||
```python
|
||||
def compare_values(value1: T, value2: T, /) -> bool:
|
||||
...
|
||||
|
||||
def compare_values(__value1: T, __value2: T) -> bool:
|
||||
...
|
||||
```
|
||||
|
||||
### Annotating Decorators
|
||||
Decorators modify the behavior of a class or a function. Providing annotations for decorators is straightforward if the decorator retains the original signature of the decorated function.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user