Skip to content

gh-156233: Fixing a couple of typos and a few code snippet errors in Python docs - #156475

Open
willy-b wants to merge 1 commit into
python:mainfrom
willy-b:fix-156233
Open

gh-156233: Fixing a couple of typos and a few code snippet errors in Python docs#156475
willy-b wants to merge 1 commit into
python:mainfrom
willy-b:fix-156233

Conversation

@willy-b

@willy-b willy-b commented Aug 27, 2026

Copy link
Copy Markdown

Hello Python team!

Just sending a PR to fix a couple of typos and a few code snippet errors in Python docs. No changes outside of a few .rst files used to generate content on docs.python.org are made to the Python project. These changes are not claimed to fix other unreported possible issues in the documentation, but rather just the items currently mentioned in #156233 .


On https://docs.python.org/3.16/howto/logging-cookbook.html (archived as is at https://web.archive.org/web/20260827054643/https://docs.python.org/3.16/howto/logging-cookbook.html )

  • In the sentence

    to the log). Nevertheless, the above should be adaptable to your speciric needs. With

    Nevertheless, the above should be adaptable to your speciric needs.

    "speciric" should be "specific".


On https://docs.python.org/3.16/library/logging.config.html (archived as is at https://web.archive.org/web/20260827041728/https://docs.python.org/3.16/library/logging.config.html )

  • In the example

    You can also specify a special key '.' whose value is a mapping of attribute names to values. If found, the specified attributes will be set on the user-defined object before it is returned. Thus, with the following configuration:

{
'()' : 'my.package.customFormatterFactory',
'bar' : 'baz',
'spam' : 99.9,
'answer' : 42,
'.' {
  'foo': 'bar',
  'baz': 'bozz'
}
}

It seems the key "." is missing a ":" before its value to avoid ':' expected after dictionary key (<string>, line 6)' for the above.


On https://docs.python.org/3.16/library/pdb.html#pdbcommand-exceptions (archived as is at https://web.archive.org/web/20260827042203/https://docs.python.org/3.16/library/pdb.html#pdbcommand-exceptions )

  • nit: In the example

    def out():
       try:
           middle()
       except Exception as e:
           raise ValueError("reraise middle() error") from e
    
    def middle():
       try:
           return inner(0)
       except Exception as e:
           raise ValueError("Middle fail")
    
    def inner(x):
       1 / x
    
    out()
    

    There is an extra space on the beginning of the last line out(), which prevents the snippet from running exactly as is if copy-pasted.


In the latest version of https://docs.python.org/3/howto/mro.html#python-2-3-mro (archived as is at https://web.archive.org/web/20260822145356/https://docs.python.org/3/howto/mro.html#python-2-3-mro )

In the sentence

    Then repeat the operation until all the class are removed or it is impossible to find good heads.

it seems "all the class" should be "all the classes".

I am not trying in this PR to fix the non-default type parameter 'TypeVarWithBound' follows default type parameter for the overly_generic example on https://docs.python.org/3.16/reference/compound_stmts.html yet ( caused by

TypeVarWithDefault = int,
) which I discovered and reported in the same ticket because while a simple reordering fixes that to be runnable again in Python there may be other updates required for that example to work properly with type checkers like mypy , so I will handle that separately if that is ok.


Let me know if there are any additional backport PRs or other language repos for the docs I need to open manually to propagate these changes (if the automated backports don't end up running for this PR).

Thanks so much!

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34261231 | 📁 Comparing cb57023 against main (eb08902)

  🔍 Preview build  

3 files changed
± howto/logging-cookbook.html
± howto/mro.html
± library/logging.config.html

@StanFromIreland

Copy link
Copy Markdown
Member

I just noticed #156233 (comment), can you please fix it here as well. Indeed it's currently a SyntaxError. To fix it, move TypeVarWithDefault after the non-defaulted type parameters (that is, after TypeVarWithConstraints, and also realign the function parameters to match), since a non-default type parameter cannot follow one with a default.

    def overly_generic[
       SimpleTypeVar,
-      TypeVarWithDefault = int,
       TypeVarWithBound: int,
       TypeVarWithConstraints: (str, bytes),
+      TypeVarWithDefault = int,
       *SimpleTypeVarTuple = (int, float),
       **SimpleParamSpec = (str, bytearray),
    ](
       a: SimpleTypeVar,
-      b: TypeVarWithDefault,
-      c: TypeVarWithBound,
-      d: Callable[SimpleParamSpec, TypeVarWithConstraints],
+      b: TypeVarWithBound,
+      c: TypeVarWithConstraints,
+      d: Callable[SimpleParamSpec, TypeVarWithDefault],
       *e: SimpleTypeVarTuple,
    ): ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants