Skip to content

Header variable is always used, even when default is None #167

@liiight

Description

@liiight

Describe the bug
When using the Header type for a variable, it is always added to the request, even if the default of None is used

To Reproduce

import uplink


class HTTPBin(uplink.Consumer):

    @uplink.returns.json
    @uplink.get('headers')
    def headers(self, foo: uplink.Header = None):
        pass


bin = HTTPBin(base_url='https://httpbin.org')
print(bin.headers())

Result: {'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Foo': 'None', 'Host': 'httpbin.org', 'User-Agent': 'python-requests/2.20.1'}}

Expected behavior
When the default value of None is used, the header should not be added to the request, as that is the expected behavior. It is also how Query works and it should be consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions