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

Skip to content

braintree.Environment is missing attributes #10905

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

Closed
cuu508 opened this issue Oct 18, 2023 · 1 comment · Fixed by #10907
Closed

braintree.Environment is missing attributes #10905

cuu508 opened this issue Oct 18, 2023 · 1 comment · Fixed by #10907
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module

Comments

@cuu508
Copy link

cuu508 commented Oct 18, 2023

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]
AlexWaygood added a commit that referenced this issue Oct 18, 2023
@srittau srittau added the stubs: incomplete Annotations or sub-modules missing from an existing package or module label Oct 18, 2023
@cuu508
Copy link
Author

cuu508 commented Oct 19, 2023

Awesome, thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants