Skip to content

Make a module's imports reference-able for doctypes? #20

@lagru

Description

@lagru

Consider the following example

# some_module.py

"""Module docstring

Attributes
----------
logger : logging.Logger
"""

import logging

logger = logging.getLogger(__name__)

Currently, referencing logging.Logger for the attribute will be reported as an "unknown name" and is replaced with from typing import Any as logging_Logger. Instead import logging could be treated as a module-scoped

[tool.docstub.known_imports]
logging = {import = "logging"}

I'm not sure if this implicit behavior would be more confusing than it is convenient. Should from logging import Logger work too? How would I differentiate that from an imported function? I could simply say that I rely on type checkers to check the correctness...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions