Skip to content
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

PartMap fails with converter=None #221

Closed
EmmaTinten opened this issue Mar 31, 2021 · 1 comment · Fixed by #231
Closed

PartMap fails with converter=None #221

EmmaTinten opened this issue Mar 31, 2021 · 1 comment · Fixed by #231
Milestone

Comments

@EmmaTinten
Copy link

EmmaTinten commented Mar 31, 2021

Using multipart and Partmap results in a NoneType error.

To Reproduce
Create a simple multipart def:

@multipart
@post('engine-rest/deployment/create')
 def deployment_create(
      self,
      **params: PartMap,
): 
      pass

and use it. Will produce an error:

site-packages/uplink/converters/keys.py", line 70, in <genexpr>
    return dict((k, converter(value[k])) for k in value)
TypeError: 'NoneType' object is not callable

Expected behavior
The submitted params should work just like the QueryMap.

@CodyTeague
Copy link

CodyTeague commented Jun 23, 2021

Seeing the same issue with FieldMap which is fixed by the above pull request.

    @returns(MergeRequestDetailSchema)
    @response_handler(raise_for_status)
    @put(
        "projects/{project_id}/merge_requests/{merge_request_iid}",
        args={
            "project_id": Path("project_id"),
            "merge_request_iid": Path("merge_request_iid"),
            "assignee_ids": Field("assignee_ids[]"),
            "merge_request_data": FieldMap,
        },
    )
    def update_merge_request(
        self,
        project_id: int,
        merge_request_iid: int,
        assignee_ids=None,
        **merge_request_data,
    ) -> MergeRequestDetail:
    merge_request = get_api().update_merge_request(
  File "/usr/local/lib/python3.9/site-packages/uplink/builder.py", line 95, in __call__
    self._request_definition.define_request(request_builder, args, kwargs)
  File "/usr/local/lib/python3.9/site-packages/uplink/commands.py", line 284, in define_request
    self._argument_handler.handle_call(
  File "/usr/local/lib/python3.9/site-packages/uplink/arguments.py", line 151, in handle_call
    self.handle_call_args(request_builder, call_args)
  File "/usr/local/lib/python3.9/site-packages/uplink/arguments.py", line 156, in handle_call_args
    annotation.modify_request(request_builder, call_args[name])
  File "/usr/local/lib/python3.9/site-packages/uplink/arguments.py", line 181, in modify_request
    converted_value = converter(value) if converter else value
  File "/usr/local/lib/python3.9/site-packages/uplink/converters/keys.py", line 71, in convert
    return dict((k, converter(value[k])) for k in value)
  File "/usr/local/lib/python3.9/site-packages/uplink/converters/keys.py", line 71, in <genexpr>
    return dict((k, converter(value[k])) for k in value)

@prkumar prkumar added this to the v0.9.5 milestone Aug 2, 2021
prkumar added a commit that referenced this issue Dec 31, 2021
* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add link to GitHub Discussions for repo in README

* Update "Question" GitHub issue template

* Fix @uplink.*Map to not throw error if converter is None

Fixes #221

* Fix B018 flake error

Flake is failing with "B018 Found useless expression."

https://app.travis-ci.com/github/prkumar/uplink/jobs/553555288

* Add 3.9 and 3.10.1 to travis build (#239)

* Add 3.9 and 3.10 to travis build

* Replace 3.10 with 3.10-dev

* Update travis to use Ubuntu 18.04

18.04 has 3.10.0 and 3.10.1 according to: 
https://docs.travis-ci.com/user/languages/python/

* Bump python 3.10 to 3.10.1 in travis

* Unpin pytest version

Travis build for 3.10.1 failed because of issue in pytest that was fixed in a later release: pytest-dev/pytest#8540

* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add python 2.7 to travis build

* Omit "keywords" attribute when invoking setup for py2.7

Context: pypa/pipenv#4357 (comment)

* Pin pipenv==2018.11.26 for py2.7 travis build

Context: pypa/pipenv#4357 (comment)

* Fix syntax error in travis config file

* Try pinning pipenv version in tox.ini

* Make integration tests work with py2.7

* Make integration tests work with py2.7

* Fix flake8 E231 error

Co-authored-by: P. Raj Kumar <raj.pritvi.kumar@gmail.com>
Co-authored-by: Alexander Shadchinr <shadchin@users.noreply.github.com>
@prkumar prkumar mentioned this issue Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants