jaraco / pip-run

pip-run - dynamic dependency loader for Python
MIT License
130 stars 19 forks source link

TypeError: split_at() got an unexpected keyword argument 'maxsplit' #62

Closed colossusb closed 1 year ago

colossusb commented 1 year ago
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/localdata/some_user/src/test_utils/venv/lib/python3.8/site-packages/pip-run.py", line 4, in <module>
    __name__ == '__main__' and run()
  File "/localdata/some_user/src/test_utils/venv/lib/python3.8/site-packages/pip_run/__init__.py", line 15, in run
    pip_args, params = commands.parse_script_args(args)
  File "/localdata/some_user/src/test_utils/venv/lib/python3.8/site-packages/pip_run/commands.py", line 58, in parse_script_args
    return _separate_dash(args)
  File "/localdata/some_user/src/test_utils/venv/lib/python3.8/site-packages/pip_run/commands.py", line 48, in _separate_dash
    pre, post = split_at(args, '--'.__eq__, maxsplit=1)
TypeError: split_at() got an unexpected keyword argument 'maxsplit'

The maxsplit keyword argument for split_at was only introduced from version 8.3.0 of more-itertools

Since there is no minimum version specified in https://github.com/jaraco/pip-run/blob/c72c1dd41e29b82d8ed05e38cea4b43a4b42c07a/setup.cfg#L26

Then if the users environment already contains this module at a lower version, then they will encounter the error above

Suggest the requirement be updated to more_itertools>=8.3.0?

To replicate (Python3.8):

virtualenv venv -p python3 && source ./venv/bin/activate
pip install more_itertools==8.2.0
pip install pip-run
python3 -m pip-run some_url -- -m some_module
...
TypeError: split_at() got an unexpected keyword argument 'maxsplit'
jaraco commented 1 year ago

Thanks for the tracking down the issue and filing the report. Your detailed description made it super easy to implement the fix. The fix should be released with 9.2.1.