python / python/typeshed

Should logging.Handler.lock allow None?

Open
#13,381 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

Since https://github.com/python/cpython/commit/74723e11109a320e628898817ab449b3dad9ee96 (in CPython 3.13 and later), a variety of calls of Handler.acquire() and Handler.release() got converted into with Handler.lock.

As a result, unless you're overriding Handler.handle, Handler.lock cannot be None, which it could be previously.

Note that logging.NullHandler does actually set lock to None in the stdlib, but it does override Handler.handle.

I’m unsure about the policy for typeshed is about instance variables whose valid values depend on whether a particular method is overridden.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CPython commit 74723e11109a320e628898817ab449b3dad9ee96 and compare Handler.lock, acquire(), release(), and handle() with the typeshed declarations. Check how NullHandler's lock and overridden handle() are represented, then review typeshed policy for instance variables whose valid values depend on overrides. Done means the annotation reflects supported CPython behavior and the policy question is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.