Thanks to visit codestin.com
Credit goes to github.com

Skip to content

braintree.Environment is missing attributes #10905

Closed
@cuu508

Description

@cuu508

Looking at the braintree source, the braintree.Environment class has references to preset Environment instances:

>>> import braintree
>>> dir(braintree.Environment)
['All', 'Development', 'Production', 'QA', 'Sandbox', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'auth_url', 'base_url', 'braintree_root', 'graphql_port', 'graphql_server', 'graphql_server_and_port', 'parse_environment', 'port', 'protocol', 'server', 'server_and_port']

Notice the All, Development, Production, QA, Sandbox attributes above.

It seems braintree type stubs don't know about these. In my client code I configure the braintree library like so:

braintree.Configuration.configure(
    **{
        "environment": braintree.Environment.Sandbox,
        "merchant_id": "...",
        "public_key": "...",
        "private_key": "...",
    }
)

This code triggers a mypy warning:

path/to/file.py:123: error: "type[Environment]" has no attribute "Sandbox"  [attr-defined]

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions