Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible small mistake in the documentation of importlib.util.LazyLoader.factory #101390

Closed
busywhitespace opened this issue Jan 28, 2023 · 2 comments
Labels
docs Documentation in the Doc dir topic-importlib

Comments

@busywhitespace
Copy link
Contributor

busywhitespace commented Jan 28, 2023

The documentation of LoazyLoader.factory in the module importlib.util says:

classmethod factory(loader)

A static method which returns a callable that creates a lazy loader. This is meant to be used in situations where the loader is passed by class instead of by instance.

The problem is that there is a mixing of words classmethod and static method. And the documentation defines the static method as ... Static method objects are created by the built-in staticmethod() constructor.

The source code for the method is:

@classmethod
def factory(cls, loader):
    """Construct a callable which returns the eager loader made lazy."""
    cls.__check_eager_loader(loader)
    return lambda *args, **kwargs: cls(loader(*args, **kwargs))

So, in my opition, "a static method" in the documentation should be corrected to "a class method".

I've created the PR in case the issue is right.

Linked PRs

@brettcannon
Copy link
Member

The specific code lines in question:

@classmethod
def factory(cls, loader):

So @busywhitespace is correct that the docs are wrong about calling it a static method.

brettcannon pushed a commit that referenced this issue Feb 10, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 10, 2023
…roperly call it a class method (pythonGH-101391)

(cherry picked from commit 17143e2)

Co-authored-by: busywhitespace <busywhitespace@tuta.io>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 10, 2023
…roperly call it a class method (pythonGH-101391)

(cherry picked from commit 17143e2)

Co-authored-by: busywhitespace <busywhitespace@tuta.io>
brettcannon pushed a commit that referenced this issue Feb 11, 2023
…properly call it a class method (GH-101391) (#GH-101813)

gh-101390: Fix docs for `imporlib.util.LazyLoader.factory` to properly call it a class method (GH-101391)
(cherry picked from commit 17143e2)

Co-authored-by: busywhitespace <busywhitespace@tuta.io>
brettcannon pushed a commit that referenced this issue Feb 11, 2023
…properly call it a class method (GH-101391) (GH-101814)

gh-101390: Fix docs for `imporlib.util.LazyLoader.factory` to properly call it a class method (GH-101391)
(cherry picked from commit 17143e2)

Co-authored-by: busywhitespace <busywhitespace@tuta.io>
carljm added a commit to carljm/cpython that referenced this issue Feb 13, 2023
* main:
  pythongh-101810: Remove duplicated st_ino calculation (pythonGH-101811)
  pythongh-92547: Purge sqlite3_enable_shared_cache() detection from configure (python#101873)
  pythonGH-100987: Refactor `_PyInterpreterFrame` a bit, to assist generator improvement. (pythonGH-100988)
  pythonGH-87849: Simplify stack effect of SEND and specialize it for generators and coroutines. (pythonGH-101788)
  Correct trivial grammar in reset_mock docs (python#101861)
  pythongh-101845: pyspecific: Fix i18n for availability directive (pythonGH-101846)
  pythongh-89792: Limit test_tools freeze test build parallelism based on the number of cores (python#101841)
  pythongh-85984: Utilize new "winsize" functions from termios in pty tests. (python#101831)
  pythongh-89792: Prevent test_tools from copying 1000M of "source" in freeze test (python#101837)
  Fix typo in test_fstring.py (python#101823)
  pythonGH-101797: allocate `PyExpat_CAPI` capsule on heap (python#101798)
  pythongh-101390: Fix docs for `imporlib.util.LazyLoader.factory` to properly call it a class method (pythonGH-101391)
@hauntsaninja
Copy link
Contributor

Thanks, looks like this was fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-importlib
Projects
None yet
Development

No branches or pull requests

4 participants