@@ -39,7 +39,7 @@ need fixing.
3939
4040### ... Or create a local development environment
4141
42- If you prefer to run the tests & formatting locally, it's
42+ If you prefer to run the tests and formatting locally, it's
4343possible too. Follow platform-specific instructions below.
4444For more information about our available tests, see
4545[ tests/README.md] ( tests/README.md ) .
@@ -54,7 +54,7 @@ Note that some tests require extra setup steps to install the required dependenc
5454### Linux/Mac OS
5555
5656On Linux and Mac OS, you will be able to run the full test suite on Python
57- 3.9 or 3.10 .
57+ 3.9, 3.10, or 3.11 .
5858To install the necessary requirements, run the following commands from a
5959terminal window:
6060
@@ -94,7 +94,7 @@ also performed by [`Ruff`](https://github.com/astral-sh/ruff) and
9494with plugins [ ` flake8-pyi ` ] ( https://github.com/pycqa/flake8-pyi ) ,
9595and [ ` flake8-noqa ` ] ( https://github.com/plinss/flake8-noqa ) .
9696
97- The repository is equipped with a [ ` pre-commit.ci ` ] ( https://pre-commit.ci/ )
97+ The repository is equipped with a [ pre-commit.ci] ( https://pre-commit.ci/ )
9898configuration file. This means that you don't * need* to do anything yourself to
9999run the code formatters or linters. When you push a commit, a bot will run
100100those for you right away and add any autofixes to your PR. Anything
@@ -128,9 +128,8 @@ We accept stubs for third-party packages into typeshed as long as:
128128
129129The fastest way to generate new stubs is to use ` scripts/create_baseline_stubs.py ` (see below).
130130
131- Stubs for third-party packages
132- go into ` stubs ` . Each subdirectory there represents a PyPI distribution, and
133- contains the following:
131+ Stubs for third-party packages go into the ` stubs ` directory. Each subdirectory
132+ there represents a PyPI distribution, and contains the following:
134133* ` METADATA.toml ` , describing the package. See below for details.
135134* Stubs (i.e. ` *.pyi ` files) for packages and modules that are shipped in the
136135 source distribution.
@@ -193,6 +192,9 @@ supported:
193192* ` partial_stub ` (optional): This field marks the type stub package as
194193 [ partial] ( https://peps.python.org/pep-0561/#partial-stub-packages ) . This is for
195194 3rd-party stubs that don't cover the entirety of the package's public API.
195+ * ` requires_python ` (optional): The minimum version of Python required to install
196+ the type stub package. It must be in the form ` >=3.* ` . If omitted, the oldest
197+ Python version supported by typeshed is used.
196198
197199In addition, we specify configuration for stubtest in the ` tool.stubtest ` table.
198200This has the following keys:
@@ -235,7 +237,7 @@ with what you'd like to do or have ideas that will help you do it.
235237
236238Each Python module is represented by a ` .pyi ` "stub file". This is a
237239syntactically valid Python file, although it usually cannot be run by
238- Python 3 (since forward references don't require string quotes). All
240+ Python (since forward references don't require string quotes). All
239241the methods are empty.
240242
241243Python function annotations ([ PEP 3107] ( https://www.python.org/dev/peps/pep-3107/ ) )
@@ -289,7 +291,7 @@ Supported features include:
289291- [ PEP 702] ( https://peps.python.org/pep-0702/ ) (` @deprecated() ` )
290292
291293Features from the ` typing ` module that are not present in all
292- supported Python 3 versions must be imported from ` typing_extensions `
294+ supported Python versions must be imported from ` typing_extensions `
293295instead in typeshed stubs. This currently affects:
294296
295297- ` TypeAlias ` (new in Python 3.10)
@@ -379,16 +381,16 @@ MAXYEAR: int
379381MINYEAR : int
380382
381383class date :
382- def __new__ (cls : Type[_S] , year : int , month : int , day : int ) -> _S : ...
384+ def __new__ (cls , year : SupportsIndex , month : SupportsIndex , day : SupportsIndex ) -> Self : ...
383385 @ classmethod
384- def fromtimestamp (cls : Type[_S], __timestamp : float ) -> _S : ...
386+ def fromtimestamp (cls , timestamp : float , / ) -> Self : ...
385387 @ classmethod
386- def today (cls : Type[_S] ) -> _S : ...
388+ def today (cls ) -> Self : ...
387389 @ classmethod
388- def fromordinal (cls : Type[_S], __n : int ) -> _S : ...
390+ def fromordinal (cls , n : int , / ) -> Self : ...
389391 @ property
390392 def year (self ) -> int : ...
391- def replace (self , year : int = ... , month : int = ... , day : int = ... ) -> date : ...
393+ def replace (self , year : SupportsIndex = ... , month : SupportsIndex = ... , day : SupportsIndex = ... ) -> Self : ...
392394 def ctime (self ) -> str : ...
393395 def weekday (self ) -> int : ...
394396```
@@ -438,8 +440,8 @@ Some further tips for good type hints:
438440 ` Optional[X] ` ;
439441* import collections (` Mapping ` , ` Iterable ` , etc.)
440442 from ` collections.abc ` instead of ` typing ` ;
441- * avoid invariant collection types (` list ` , ` dict ` ) in argument
442- positions , in favor of covariant types like ` Mapping ` or ` Sequence ` ;
443+ * avoid invariant collection types (` list ` , ` dict ` ) for function
444+ parameters , in favor of covariant types like ` Mapping ` or ` Sequence ` ;
443445* avoid union return types: https://github.com/python/mypy/issues/1693 ;
444446* use platform checks like ` if sys.platform == 'win32' ` to denote
445447 platform-dependent APIs;
@@ -485,8 +487,8 @@ context manager is meant to be subclassed, pick `bool | None`.
485487See https://github.com/python/mypy/issues/7214 for more details.
486488
487489` __enter__ ` methods and other methods that return instances of the
488- current class should be annotated with the ` _typeshed .Self` type
489- variable ([ example] ( https://github.com/python/typeshed/pull/5698 ) ).
490+ current class should be annotated with ` typing_extensions .Self`
491+ ([ example] ( https://github.com/python/typeshed/blob/3581846/stdlib/contextlib.pyi#L151 ) ).
490492
491493### Naming
492494
@@ -556,7 +558,7 @@ Consider the following (simplified) signature of `re.Match[str].group`:
556558
557559``` python
558560class Match :
559- def group (self , __group : str | int ) -> str | Any: ...
561+ def group (self , group : str | int , / ) -> str | Any: ...
560562```
561563
562564The ` str | Any ` seems unnecessary and weird at first.
0 commit comments