jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.29k stars 473 forks source link

TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist' #386

Open johncoxon opened 1 year ago

johncoxon commented 1 year ago

I'm running the following code:

from notion.client import NotionClient
client = NotionClient(token_v2="<token>")

and it fails with the below error:

File /opt/homebrew/Caskroom/mambaforge/base/envs/notion/lib/python3.11/site-packages/notion/client.py:77, in NotionClient.__init__(self, token_v2, monitor, start_monitoring, enable_caching, cache_key, email, password, client_specified_retry)
     66 def __init__(
     67     self,
     68     token_v2=None,
   (...)
     75     client_specified_retry=None,
     76 ):
---> 77     self.session = create_session(client_specified_retry)
     78     if token_v2:
     79         self.session.cookies = cookiejar_from_dict({"token_v2": token_v2})

File /opt/homebrew/Caskroom/mambaforge/base/envs/notion/lib/python3.11/site-packages/notion/client.py:39, in create_session(client_specified_retry)
     37     retry = client_specified_retry
     38 else:
---> 39     retry = Retry(
     40         5,
     41         backoff_factor=0.3,
     42         status_forcelist=(502, 503, 504),
     43         # CAUTION: adding 'POST' to this list which is not technically idempotent
     44         method_whitelist=(
     45             "POST",
     46             "HEAD",
     47             "TRACE",
     48             "GET",
     49             "PUT",
     50             "OPTIONS",
     51             "DELETE",
     52         ),
     53     )
     54 adapter = HTTPAdapter(max_retries=retry)
     55 session.mount("https://", adapter)

TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'

I'm installing the package using the following conda environment yml:

name: notion
channels:
  - conda-forge
dependencies:
  - python
  - beautifulsoup4
  - bs4
  - cached-property
  - certifi
  - charset-normalizer
  - commonmark
  - dictdiffer
  - idna
  - jupyter
  - jupyterlab
  - matplotlib
  - mistletoe
  - python-slugify
  - requests
  - soupsieve
  - text-unidecode
  - tzlocal
  - urllib3
  - pip
  - pip:
    - notion
    - md2notion

The package list in the conda environment I'm in is as follows:

# Name                    Version                   Build  Channel
anyio                     3.6.2              pyhd8ed1ab_0    conda-forge
appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py311he2be06e_3    conda-forge
asttokens                 2.2.1              pyhd8ed1ab_0    conda-forge
async-lru                 2.0.2              pyhd8ed1ab_0    conda-forge
attrs                     23.1.0             pyh71513ae_1    conda-forge
babel                     2.12.1             pyhd8ed1ab_1    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.12.2             pyha770c72_0    conda-forge
bleach                    6.0.0              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h1a8c8d9_8    conda-forge
brotli-bin                1.0.9                h1a8c8d9_8    conda-forge
bs4                       0.0.1                    pypi_0    pypi
bzip2                     1.0.8                h3422bc3_4    conda-forge
ca-certificates           2023.5.7             hf0a4a13_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
certifi                   2023.5.7           pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py311hae827db_3    conda-forge
charset-normalizer        3.1.0              pyhd8ed1ab_0    conda-forge
comm                      0.1.3              pyhd8ed1ab_0    conda-forge
commonmark                0.9.1                      py_0    conda-forge
contourpy                 1.0.7           py311hd6ee22a_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
debugpy                   1.6.7           py311ha397e9f_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dictdiffer                0.9.0              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 1.2.0              pyhd8ed1ab_0    conda-forge
flit-core                 3.9.0              pyhd8ed1ab_0    conda-forge
fonttools                 4.39.4          py311heffc1b2_0    conda-forge
freetype                  2.12.1               hd633e50_1    conda-forge
future                    0.18.3             pyhd8ed1ab_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        6.6.0              pyha770c72_0    conda-forge
importlib_metadata        6.6.0                hd8ed1ab_0    conda-forge
importlib_resources       5.12.0             pyhd8ed1ab_0    conda-forge
ipykernel                 6.23.1             pyh736e0ef_0    conda-forge
ipython                   8.13.2             pyhd1c38e8_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                8.0.6              pyhd8ed1ab_0    conda-forge
jedi                      0.18.2             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
jupyter                   1.0.0           py311h267d04e_8    conda-forge
jupyter-lsp               2.1.0              pyhd8ed1ab_0    conda-forge
jupyter_client            8.2.0              pyhd8ed1ab_0    conda-forge
jupyter_console           6.6.3              pyhd8ed1ab_0    conda-forge
jupyter_core              5.3.0           py311h267d04e_0    conda-forge
jupyter_events            0.6.3              pyhd8ed1ab_0    conda-forge
jupyter_server            2.6.0              pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.4.4              pyhd8ed1ab_1    conda-forge
jupyterlab                4.0.1              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_server         2.22.1             pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        3.0.7              pyhd8ed1ab_1    conda-forge
kiwisolver                1.4.4           py311hd6ee22a_1    conda-forge
lcms2                     2.15                 hd835a16_1    conda-forge
lerc                      4.0.0                h9a09cb3_0    conda-forge
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libbrotlicommon           1.0.9                h1a8c8d9_8    conda-forge
libbrotlidec              1.0.9                h1a8c8d9_8    conda-forge
libbrotlienc              1.0.9                h1a8c8d9_8    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcxx                    16.0.4               h4653b0c_0    conda-forge
libdeflate                1.18                 h1a8c8d9_0    conda-forge
libexpat                  2.5.0                hb7217d7_1    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgfortran               5.0.0           12_2_0_hd922786_31    conda-forge
libgfortran5              12.2.0              h0eea778_31    conda-forge
libjpeg-turbo             2.1.5.1              h1a8c8d9_0    conda-forge
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libopenblas               0.3.21          openmp_hc731615_3    conda-forge
libpng                    1.6.39               h76d750c_0    conda-forge
libsodium                 1.0.18               h27ca646_1    conda-forge
libsqlite                 3.42.0               hb31c410_0    conda-forge
libtiff                   4.5.0                h4f7d55c_6    conda-forge
libwebp-base              1.3.0                h1a8c8d9_0    conda-forge
libxcb                    1.15                 hf346824_0    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
llvm-openmp               16.0.4               h1c12783_0    conda-forge
markupsafe                2.1.2           py311he2be06e_0    conda-forge
matplotlib                3.7.1           py311ha1ab1f8_0    conda-forge
matplotlib-base           3.7.1           py311h99a5f44_0    conda-forge
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
md2notion                 2.4.1                    pypi_0    pypi
mistletoe                 1.0.1              pyhd8ed1ab_0    conda-forge
mistune                   2.0.5              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
nbclassic                 1.0.0              pyhb4ecaf3_1    conda-forge
nbclient                  0.8.0              pyhd8ed1ab_0    conda-forge
nbconvert                 7.4.0              pyhd8ed1ab_0    conda-forge
nbconvert-core            7.4.0              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.4.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.8.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
nest-asyncio              1.5.6              pyhd8ed1ab_0    conda-forge
notebook                  6.5.4              pyha770c72_0    conda-forge
notebook-shim             0.2.3              pyhd8ed1ab_0    conda-forge
notion                    0.0.28                   pypi_0    pypi
numpy                     1.24.3          py311hb8f3215_0    conda-forge
openjpeg                  2.5.0                hbc2ba62_2    conda-forge
openssl                   3.1.0                h53f4e23_3    conda-forge
overrides                 7.3.1              pyhd8ed1ab_0    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
pandoc                    2.19.2               hce30654_2    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.5.0           py311h095fde6_1    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              3.5.1              pyhd8ed1ab_0    conda-forge
prometheus_client         0.17.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.38             pyha770c72_0    conda-forge
prompt_toolkit            3.0.38               hd8ed1ab_0    conda-forge
psutil                    5.9.5           py311he2be06e_0    conda-forge
pthread-stubs             0.4               h27ca646_1001    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.15.1             pyhd8ed1ab_0    conda-forge
pyobjc-core               9.1.1           py311h490943d_0    conda-forge
pyobjc-framework-cocoa    9.1.1           py311h490943d_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.3          py311he2be06e_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.3          h1456518_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.17.1             pyhd8ed1ab_0    conda-forge
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python-slugify            8.0.1              pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py311he2be06e_5    conda-forge
pyzmq                     25.0.2          py311h0f351f6_0    conda-forge
readline                  8.2                  h92ec313_1    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
rfc3339-validator         0.1.4              pyhd8ed1ab_0    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
send2trash                1.8.2              pyhd1c38e8_0    conda-forge
setuptools                67.7.2             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.2.post1        pyhd8ed1ab_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
terminado                 0.17.1             pyhd1c38e8_0    conda-forge
text-unidecode            1.3                        py_0    conda-forge
tinycss2                  1.2.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tornado                   6.3.2           py311heffc1b2_0    conda-forge
traitlets                 5.9.0              pyhd8ed1ab_0    conda-forge
typing-extensions         4.6.2                hd8ed1ab_0    conda-forge
typing_extensions         4.6.2              pyha770c72_0    conda-forge
typing_utils              0.1.0              pyhd8ed1ab_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
tzlocal                   5.0.1           py311h267d04e_0    conda-forge
unidecode                 1.3.6              pyhd8ed1ab_0    conda-forge
urllib3                   2.0.2              pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.6              pyhd8ed1ab_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.5.2              pyhd8ed1ab_0    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
widgetsnbextension        4.0.7              pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.11               hb547adb_0    conda-forge
xorg-libxdmcp             1.1.3                h27ca646_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
yaml                      0.2.5                h3422bc3_2    conda-forge
zeromq                    4.3.4                hbdafb3b_1    conda-forge
zipp                      3.15.0             pyhd8ed1ab_0    conda-forge
zstd                      1.5.2                hf913c23_6    conda-forge
tanoinc commented 1 year ago

I believe this is related to this issue with urllib3 where method_whitelist got replaced by allowed_methods. I think the parameter can be replaced to the new name 🤔

johncoxon commented 1 year ago

Replacing it in client.py works, yep! Thank you, will leave this open until your pull request is approved.

kaedea commented 1 year ago

I believe this is related to this issue with urllib3 where method_whitelist got replaced by allowed_methods. I think the parameter can be replaced to the new name 🤔

Might have a quick-fix by:

pip install git+https://github.com/tanoinc/notion-py.git@3f1b67fac472a39c3ac07e490769ab7a3deb7564