You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't upgrade to Braintree 4.18.1 / Python 3.10.9 (DeprecationWarning: Use ProtectionLevel enum instead) #148
Braintree 4.18.1 (trying to upgrade from 4.17.1)
Python 3.10.9 (recently upgraded; works with 4.17.1)
Running locally on Mac OS X 13.1
The upgrade is causing automated tests with import braintree to fail with the following:
...
import braintree
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/__init__.py:10: in <module>
from braintree.braintree_gateway import BraintreeGateway
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/braintree_gateway.py:10: in <module>
from braintree.dispute_gateway import DisputeGateway
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/dispute_gateway.py:4: in <module>
from braintree.dispute import Dispute
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/dispute.py:8: in <module>
class Dispute(AttributeGetter):
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/dispute.py:72: in Dispute
class ChargebackProtectionLevel(object):
../Library/Caches/pypoetry/virtualenvs/xxx-08n5XoMP-py3.10/lib/python3.10/site-packages/braintree/dispute.py:80: in ChargebackProtectionLevel
warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning)
E DeprecationWarning: Use ProtectionLevel enum instead
👋 thanks for reaching out! In v 4.18.0 we deprecated ChargebackProtectionLevel. You've got two options in my opinion:
update your code to use ProtectionLevel instead of ChargebackProtectionLevel
update your tests to ignore these level warnings (not ideal, but technically gets your tests back up and running until you can update your code to use ProtectionLevel)
I don't think you understood my report. We are not using ChargebackProtectionLevel anywhere in our code. I am simply trying to import braintree, and it is failing.
If you look at the full stack trace and compare your code, this is why: the class is still there.
@tammyalexandra I've tried replicating this issue spinning up a Docker image that's got python 3.10 and then running a test file that imports the braintree library, and I'm not able to reproduce this error. Are you running tests in development mode?
I could reproduce it by simply running python -W default and then import braintree. By default, the DeprecationWarnings are now shown, so you need to enable them specifically, however pytest (at least with our settings) shows these errors.
That draft PR had some breaking changes that made it an unfeasible solution unfortunately. I would like to circle back to what @hollabaq86 asked before though. The only way I could replicate the errors from the original description on this issue was to run tests or import braintree with -W error. This makes me think there may be some hidden variables configured outside of the SDK that are causing python warnings to be raised to exceptions. This doc on PYTHONWARNINGS seems to confirm that idea.
How are you all setting the PYTHONWARNINGS variable? @pehala you metioned using -W deafult, did that cause errors or just surface the deprecation warnings?
We are using this library in our tests with pytest and we see these errors. It is annoying for us as those errors are not in our code. It does not cause failures in the tests itself at least for our use case.
I think it should be reopen because deprecation warning should not be raised on import of the module but only when accessing the deprecated ChargebackProtectionLevel. #155 fix that.
The current behavior is annoying because it prevents to use the library with -Werror.
This is still causing me problems two years on. Just upgraded to Python 3.12 & now up to Braintree 4.29.0 4.33.1 (happening even after the upgrade).
When we run our e2e tests, the server is failing to start because a DeprecationWarning from the this package is being treated as an error in Python 3.12.
Activity
hollabaq86 commentedon Feb 7, 2023
👋 thanks for reaching out! In v 4.18.0 we deprecated ChargebackProtectionLevel. You've got two options in my opinion:
Hope this helps!
tammyalexandra commentedon Feb 7, 2023
I don't think you understood my report. We are not using
ChargebackProtectionLevelanywhere in our code. I am simply trying toimport braintree, and it is failing.If you look at the full stack trace and compare your code, this is why: the class is still there.
https://github.com/braintree/braintree_python/blob/master/braintree/dispute.py#L72
hollabaq86 commentedon Feb 9, 2023
Hey @tammyalexandra thanks for the clarification. Going to re-open this issue and take a deeper look.
hollabaq86 commentedon Feb 9, 2023
@tammyalexandra I've tried replicating this issue spinning up a Docker image that's got python 3.10 and then running a test file that imports the braintree library, and I'm not able to reproduce this error. Are you running tests in development mode?
How are you setting the PYTHONWARNINGS variable?
pehala commentedon Apr 6, 2023
I could reproduce it by simply running
python -W defaultand thenimport braintree. By default, the DeprecationWarnings are now shown, so you need to enable them specifically, howeverpytest(at least with our settings) shows these errors.hollabaq86 commentedon Apr 10, 2023
for internal tracking, issue 7868
dod-cogbuehi commentedon May 16, 2023
Is there any update on this draft PR? We're experiencing the same issue when attempting to update braintree
saralvasquez commentedon Jun 15, 2023
That draft PR had some breaking changes that made it an unfeasible solution unfortunately. I would like to circle back to what @hollabaq86 asked before though. The only way I could replicate the errors from the original description on this issue was to run tests or import braintree with
-W error. This makes me think there may be some hidden variables configured outside of the SDK that are causing python warnings to be raised to exceptions. This doc on PYTHONWARNINGS seems to confirm that idea.How are you all setting the
PYTHONWARNINGSvariable? @pehala you metioned using-W deafult, did that cause errors or just surface the deprecation warnings?pehala commentedon Jun 15, 2023
We are using this library in our tests with
pytestand we see these errors. It is annoying for us as those errors are not in our code. It does not cause failures in the tests itself at least for our use case.hollabaq86 commentedon Jun 15, 2023
pytest allows you to filter and suppress warnings, since this isn't causing failures I'm going to go ahead and close this issue.
Raise deprecation warning only when attribute is accessed
Raise deprecation warning only when attribute is accessed
cedk commentedon Jun 8, 2024
I think it should be reopen because deprecation warning should not be raised on import of the module but only when accessing the deprecated ChargebackProtectionLevel. #155 fix that.
The current behavior is annoying because it prevents to use the library with
-Werror.edufelipe commentedon Jan 30, 2025
+1
tammyalexandra commentedon Feb 4, 2025
This is still causing me problems two years on. Just upgraded to Python 3.12 & now up to Braintree
4.29.04.33.1 (happening even after the upgrade).When we run our e2e tests, the server is failing to start because a
DeprecationWarningfrom the this package is being treated as an error in Python 3.12.The specific warning is from dispute.py:
This warning is being converted to an error due to stricter warning handling in Python 3.12.
I recognize that this error can be filtered out; however, again, we are not even calling this feature.