Skip to content

Commit

Permalink
Be more explicit in the exclude pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Oct 22, 2024
1 parent b4c828f commit c7f8e47
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 40 deletions.
22 changes: 20 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,28 @@ repos:
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).*$'
exclude: |
(?x)^peps/pep-(
02(30|47|65|72)
|03(42|74)
|04(0[0459]|1[06]|45|51|68)
|0524
|06(51|72|93|99)
|07(05|13|24)
|31(11|18|33|46)
).*\.rst$
- id: trailing-whitespace
name: "Remove trailing whitespace"
exclude: '^peps/pep-(0[2-6]|3000|3002|31).*$'
args: [--chars, " \t"]
exclude: |
(?x)^peps/pep-(
0282
|0484
|05(17|44|63|82|86)
|061[1567]|062[56]|063[679]|064[356]|065[237]|066[029]|0679|0681|069[1245]
|07(03|06|22|25|27|28)
|3104
).*\.rst$
- id: file-contents-sorter
name: "Sort codespell ignore list"
Expand Down
1 change: 0 additions & 1 deletion peps/pep-0418/bench_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@ int main()
benchmark("time()", bench_time, 0);
return 0;
}

1 change: 0 additions & 1 deletion peps/pep-0418/clock_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ def gettime():
test_clock(name, gettime)
resolution = time.clock_getres(clock_id)
print("- announced resolution: %s" % format_duration(resolution))

1 change: 0 additions & 1 deletion peps/pep-0426/pepsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,3 @@ def main(pepno = '426'):
filemode='w', format='%(message)s')
logger.setLevel(logging.DEBUG)
main(pepno)

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

This document has been placed into the public domain.


1 change: 0 additions & 1 deletion peps/pep-0446/test_cloexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ def after_exec():
main()
else:
after_exec()

2 changes: 1 addition & 1 deletion peps/pep-0495-gap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion peps/pep-0532/circuit-breaking-protocol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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: 1 addition & 0 deletions peps/pep-0705.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,4 @@ 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: 1 addition & 0 deletions peps/pep-0713.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,4 @@ 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: 1 addition & 0 deletions peps/pep-0724.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,4 @@ 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
2 changes: 1 addition & 1 deletion peps/pep-0754.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Copyright

This document has been placed in the public domain.



..
Local Variables:
mode: indented-text
Expand Down

0 comments on commit c7f8e47

Please sign in to comment.