Skip to content

Commit

Permalink
Lint: Normalise whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Oct 22, 2024
1 parent d3b4ab6 commit b4c828f
Show file tree
Hide file tree
Showing 28 changed files with 161 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/Mark a PEP Final.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ If you're unsure about something, just leave it blank and we'll take a look.
* [ ] Any substantial changes since the accepted version approved by the SC/PEP delegate
* [ ] Pull request title in appropriate format (``PEP 123: Mark Final``)
* [ ] ``Status`` changed to ``Final`` (and ``Python-Version`` is correct)
* [ ] Canonical docs/spec linked with a ``canonical-doc`` directive
* [ ] Canonical docs/spec linked with a ``canonical-doc`` directive
(or ``canonical-pypa-spec`` for packaging PEPs,
or ``canonical-typing-spec`` for typing PEPs)
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ repos:
- id: mixed-line-ending
name: "Normalize mixed line endings"
args: [--fix=lf]
- id: end-of-file-fixer
name: "Ensure files end with a single newline"
exclude: '^peps/pep-(0[2-6]|3111|3118|3133|3146).*$'
- id: trailing-whitespace
name: "Remove trailing whitespace"
exclude: '^peps/pep-(0[2-6]|3000|3002|31).*$'

- id: file-contents-sorter
name: "Sort codespell ignore list"
files: '.codespell/ignore-words.txt'
Expand Down
2 changes: 1 addition & 1 deletion pep_sphinx_extensions/tests/peps/pep-9000.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PEP: 9000
Title: Test with authors with email addresses
Author: Francis Fussyreverend <one@example.com>,
Author: Francis Fussyreverend <one@example.com>,
Javier Soulfulcommodore <two@example.com>
Created: 20-Apr-2022
Status: Draft
Expand Down
2 changes: 1 addition & 1 deletion peps/pep-0008.rst
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ complete sentences, with each sentence ending in a period.
You should use one or two spaces after a sentence-ending period in
multi-sentence comments, except after the final sentence.

Ensure that your comments are clear and easily understandable to other
Ensure that your comments are clear and easily understandable to other
speakers of the language you are writing in.

Python coders from non-English speaking countries: please write your
Expand Down
6 changes: 3 additions & 3 deletions peps/pep-0703.rst
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ that wrap those calls. Python objects should not be allocated through
other APIs, such as raw calls to C's malloc or the C++ new operator.
Additionally, ``PyObject_Malloc`` should be used only for allocating
Python objects; it should not be used for allocating buffers,
storages, or other data structures that are not PyObjects.
storages, or other data structures that are not PyObjects.

This PEP also imposes restrictions on the pluggable allocator API
(``PyMem_SetAllocator``). When compiling without the GIL, allocators
Expand Down Expand Up @@ -967,7 +967,7 @@ per-object locking -- another thread might modify the list leading to

The problematic borrowed reference APIs are supplemented with
functions that return "new references" but are otherwise
equivalent:
equivalent:

* ``PyList_FetchItem(list, idx)`` for ``PyList_GetItem``
* ``PyDict_FetchItem(dict, key)`` for ``PyDict_GetItem``
Expand Down Expand Up @@ -1087,7 +1087,7 @@ and improve single-threaded performance. Although lock acquisition
has low overhead compared to most operations, accessing individual
elements of lists and dictionaries are fast operations (so the
locking overhead is comparatively larger) and frequent (so the
overhead has more impact).
overhead has more impact).

This section describes the challenges with implementing dictionary and
list accesses without locking followed by a description of this PEP's
Expand Down
1 change: 0 additions & 1 deletion peps/pep-0705.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,3 @@ Copyright
=========
This document is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.

2 changes: 1 addition & 1 deletion peps/pep-0706.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ However, there are some issues with this approach:
affect all subsequent operations on the same ``TarFile`` object.
This behavior is fine for most uses, but despite that, it would be very
surprising if ``TarFile.extractall`` did this by default.
- Calling ``getmembers`` can be expensive and it
- Calling ``getmembers`` can be expensive and it
`requires a seekable archive <https://github.com/python/cpython/issues/45385#issuecomment-1255615199>`__.
- When verifying members in advance, it may be necessary to track how each
member would have changed the filesystem, e.g. how symlinks are being set up.
Expand Down
1 change: 0 additions & 1 deletion peps/pep-0713.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,3 @@ Copyright

This document is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.

2 changes: 0 additions & 2 deletions peps/pep-0719.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ Copyright

This document is placed in the public domain or under the CC0-1.0-Universal
license, whichever is more permissive.


2 changes: 1 addition & 1 deletion peps/pep-0722.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ reference implementation can be included here.
from packaging.requirements import Requirement
DEPENDENCY_BLOCK_MARKER = r"(?i)^#\s+script\s+dependencies:\s*$"
def read_dependency_block(filename):
# Use the tokenize module to handle any encoding declaration.
with tokenize.open(filename) as f:
Expand Down
1 change: 0 additions & 1 deletion peps/pep-0724.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,3 @@ Copyright

This document is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.

4 changes: 2 additions & 2 deletions peps/pep-0725.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Multiple types of external dependencies can be distinguished:
Concrete packages are straightforward to understand, and are a concept present
in virtually every package management system. Virtual packages are a concept
also present in a number of packaging systems -- but not always, and the
details of their implementation varies.
details of their implementation varies.

Cross compilation
-----------------
Expand Down Expand Up @@ -186,7 +186,7 @@ The two types of concrete packages are supported by PURL_ (Package URL), which
implements a scheme for identifying packages that is meant to be portable
across packaging ecosystems. Its design is::

scheme:type/namespace/name@version?qualifiers#subpath
scheme:type/namespace/name@version?qualifiers#subpath

The ``scheme`` component is a fixed string, ``pkg``, and of the other
components only ``type`` and ``name`` are required. As an example, a package
Expand Down
10 changes: 5 additions & 5 deletions peps/pep-0727.rst
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ For example:
.. code:: java
/**
* Returns an Image object that can then be painted on the screen.
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute <a href="#{@link}">{@link URL}</a>. The name
* argument is a specifier that is relative to the url argument.
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
Expand Down
34 changes: 17 additions & 17 deletions peps/pep-0728.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Another possible use case for this is a sound way to
class Movie(TypedDict):
name: str
director: str

class Book(TypedDict):
name: str
author: str
Expand Down Expand Up @@ -194,12 +194,12 @@ to the ``extra_items`` argument. For example::

class Movie(TypedDict, extra_items=bool):
name: str

a: Movie = {"name": "Blade Runner", "novel_adaptation": True} # OK
b: Movie = {
"name": "Blade Runner",
"year": 1982, # Not OK. 'int' is not assignable to 'bool'
}
}

Here, ``extra_items=bool`` specifies that items other than ``'name'``
have a value type of ``bool`` and are non-required.
Expand All @@ -214,12 +214,12 @@ the ``extra_items`` argument::
def f(movie: Movie) -> None:
reveal_type(movie["name"]) # Revealed type is 'str'
reveal_type(movie["novel_adaptation"]) # Revealed type is 'bool'

``extra_items`` is inherited through subclassing::

class MovieBase(TypedDict, extra_items=int | None):
name: str

class Movie(MovieBase):
year: int

Expand Down Expand Up @@ -315,7 +315,7 @@ function parameters still apply::

class Movie(TypedDict, extra_items=int):
name: str

def f(**kwargs: Unpack[Movie]) -> None: ...

# Should be equivalent to:
Expand Down Expand Up @@ -356,7 +356,7 @@ unless it is declared to be ``ReadOnly`` in the superclass::

class Parent(TypedDict, extra_items=int | None):
pass

class Child(Parent, extra_items=int): # Not OK. Like any other TypedDict item, extra_items's type cannot be changed

Second, ``extra_items=T`` effectively defines the value type of any unnamed
Expand Down Expand Up @@ -384,10 +384,10 @@ For example::

class MovieBase(TypedDict, extra_items=int | None):
name: str

class AdaptedMovie(MovieBase): # Not OK. 'bool' is not assignable to 'int | None'
adapted_from_novel: bool

class MovieRequiredYear(MovieBase): # Not OK. Required key 'year' is not known to 'Parent'
year: int | None

Expand Down Expand Up @@ -478,7 +478,7 @@ checks::
class MovieDetails(TypedDict, extra_items=int | None):
name: str
year: NotRequired[int]

details: MovieDetails = {"name": "Kill Bill Vol. 1", "year": 2003}
movie: Movie = details # Not OK. While 'int' is assignable to 'int | None',
# 'int | None' is not assignable to 'int'
Expand All @@ -502,7 +502,7 @@ possible for an item to have a :term:`narrower <typing:narrow>` type than the

class Movie(TypedDict, extra_items=ReadOnly[str | int]):
name: str

class MovieDetails(TypedDict, extra_items=int):
name: str
year: NotRequired[int]
Expand All @@ -522,19 +522,19 @@ enforced::

class MovieExtraStr(TypedDict, extra_items=str):
name: str

extra_int: MovieExtraInt = {"name": "No Country for Old Men", "year": 2007}
extra_str: MovieExtraStr = {"name": "No Country for Old Men", "description": ""}
extra_int = extra_str # Not OK. 'str' is not assignable to extra items type 'int'
extra_str = extra_int # Not OK. 'int' is not assignable to extra items type 'str'

A non-closed TypedDict type implicitly allows non-required extra keys of value
type ``ReadOnly[object]``. Applying the assignability rules between this type
and a closed TypedDict type is allowed::

class MovieNotClosed(TypedDict):
name: str

extra_int: MovieExtraInt = {"name": "No Country for Old Men", "year": 2007}
not_closed: MovieNotClosed = {"name": "No Country for Old Men"}
extra_int = not_closed # Not OK.
Expand Down Expand Up @@ -636,8 +636,8 @@ For example::
def f(x: IntDict) -> None:
v: dict[str, int] = x # OK
v.clear() # OK
not_required_num_dict: IntDictWithNum = {"num": 1, "bar": 2}

not_required_num_dict: IntDictWithNum = {"num": 1, "bar": 2}
regular_dict: dict[str, int] = not_required_num_dict # OK
f(not_required_num_dict) # OK

Expand All @@ -652,7 +652,7 @@ because such dict can be a subtype of dict::

class CustomDict(dict[str, int]):
pass

not_a_regular_dict: CustomDict = {"num": 1}
int_dict: IntDict = not_a_regular_dict # Not OK

Expand Down
Loading

0 comments on commit b4c828f

Please sign in to comment.