Skip to content

Cosmos classes are exposed twice #30909

Open

Description

The main namespace azure.cosmos aliases some classes from public modules, making those classes visible from two namespaces and documented twice:

from .container import ContainerProxy
from .cosmos_client import CosmosClient
from .database import DatabaseProxy
from .user import UserProxy
from .scripts import ScriptsProxy
from .offer import Offer
from .offer import ThroughputProperties
from .documents import (
ConsistencyLevel,
DataType,
IndexKind,
IndexingMode,
PermissionMode,
ProxyConfiguration,
SSLConfiguration,
TriggerOperation,
TriggerType,
DatabaseAccount,
)
from .partition_key import PartitionKey
from .permission import Permission

image

Clearly the intent is that customers do not access the sub-modules here.

As a possible solution, since our baseline is 3.7, we should be able to use PEP562 to hide those modules from doc while being backward compatible for customers. Something like this:

def __getattr__(name):
   if name == "scripts":
      from . import _scripts
      return _scripts
   ...
   raise AttributeErrorr()

Other solutions are fine too, as long as we achieve to show in doc only one class

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

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.CosmosbugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions