Skip to content

Tracking variable whereabouts in a plugin #9010

Open
@kornicameister

Description

@kornicameister

Please provide more information to help us understand the issue:

  • Type: question
  • Referecenes:
  • Expected behavior: being able to track down variable i.e. from a process it was initialized.
    Code below should illustrate an expected behavior.
  • Actual behavior: n/a
  • mypy version: >=0.770
from luguru import logger

LOG_A = logger.opt(lazy=False)
LOG_B = logger.opt(lazy=True)

LOG_A.info('Test {}', lambda x: x)    # should work
LOG_B.info('Test {}', lambda x: x)    # error

logger.opt(lazy=False).info('Test {c}', c=lambda x: x)  # should work
logger.opt(lazy=True).info('Test {d}', d=lambda x: x)   # error

In short: with loguru you can use Callable[[], Any] for lazy loggers to avoid costly computations. But those have to be non-argument callables. Above you can find non-lazy loggers that will work just fine by doing str(callable). In other words, to rephrase question from above, how can we:

track a variable/object on which behalf a method was called?

This is quite vital because type checking cannot be done solely on a method call level because we need something from another call. There is opt method being called but having call details from it without anything to tie them to will not help too much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions