olucurious / PyFCM

Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)
http://olucurious.github.io/PyFCM/
MIT License
804 stars 205 forks source link

Replace deprecated urllib3.Retry options #280

Closed fredericojordan closed 3 years ago

fredericojordan commented 3 years ago

Starting on v1.26.0, urllib3 has deprecated Retry(method_whitelist=...) and Retry.DEFAULT_METHOD_WHITELIST.

Deprecated Retry options Retry.DEFAULT_METHOD_WHITELIST, Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST and Retry(method_whitelist=...) in favor of Retry.DEFAULT_ALLOWED_METHODS, Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT, and Retry(allowed_methods=...) (Pull #2000) Starting in urllib3 v2.0: Deprecated options will be removed

olucurious commented 3 years ago

Thanks for this PR

fredericojordan commented 3 years ago

It's my pleasure to contribute 😄

Rogalek commented 3 years ago

is it going to be released? @olucurious I almost add the same PR, because its still on develop not master.

olucurious commented 3 years ago

@Rogalek it's breaking in some environments, can you please help do more testing and share results

Rogalek commented 3 years ago

@olucurious https://github.com/olucurious/PyFCM/pull/288 - this works for me.


(venv) rogal@rogal-Legion-Y540-15IRH-PG0:~/Documents/repo/PyFCM$ python -m pytest
========================================================================================================================== test session starts ===========================================================================================================================
platform linux -- Python 3.8.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/rogal/Documents/repo/PyFCM
collected 17 items                                                                                                                                                                                                                                                       

tests/test_baseapi.py .........                                                                                                                                                                                                                                    [ 52%]
tests/test_fcm.py ........                                                                                                                                                                                                                                         [100%]

=========================================================================================================================== 17 passed in 1.65s ===========================================================================================================================```
fredericojordan commented 3 years ago

@Rogalek What is your urllib3 version? I think this only breaks for versions prior to 1.26.0

Rogalek commented 3 years ago

@fredericojordan I use your latest version and I am getting warnings all the time.

>>> import pyfcm
>>> pyfcm.__version__
'1.5.1'

and the latest version of the urllib3

Python 3.8.0 (default, Nov 23 2019, 05:36:56) 
[GCC 8.3.0] on linux
import urllib3
urllib3.__version__
'1.26.5'
fredericojordan commented 3 years ago

@Rogalek Yes, this is because the changes on this PR were reverted on v1.5.1, (see #283). So v1.5.1 won't have the changes on this PR and should be giving warnings again. Also, urllib3 is over 1.26.0, so they already have the new ALLOWED_METHODS options, so they won't break.

If you want to reproduce the issue that had to revert this PR, I guess you'd have to do something like this (haven't tested):

pip install PyFCM==1.5.0
pip install urllib3==1.25.11
python -m pytest
Rogalek commented 3 years ago

@fredericojordan yes, I understand but I already proposed another solution and it is merged to develop, tests are working if you check my comment with test results.

fredericojordan commented 3 years ago

Oh, I missed #288. I see that you forced urllib3==1.26.5, which should solve the problem (maybe urllib3>=1.26.0 could've been an option also). In this case, develop should have a working solution, which removes the deprecation warning. We just need a new release then?

olucurious commented 3 years ago

1.5.2 is live https://pypi.org/project/pyfcm/

Thanks for your contributions gentlemen 🙏🏻

olucurious commented 3 years ago

Guys, any idea? https://github.com/olucurious/PyFCM/issues/282#issuecomment-865366667

Rogalek commented 3 years ago

@olucurious maybe his version of urllib3 is deprecated? he should check python version and urllib3 version.

I am using the current pyfcm version and everything works perfectly. Warnings not occurs anymore

Python 3.8.0 (default, Nov 23 2019, 05:36:56) 
[GCC 8.3.0] on linux
import pyfcm
pyfcm.__version__
'1.5.2'
fredericojordan commented 3 years ago

@olucurious I haven't been able to fully test it, but I think this might work: #291 This forces urllib3 to be at least 1.26.0 when installing PyFCM, which is the minimum version that contains the option DEFAULT_ALLOWED_METHODS.

Rogalek commented 3 years ago

@olucurious I think this should help