Skip to content

Upload attributes assignee, assigneeDate, closeDate incorrectly stored as 1-tuples #175

@Valyrian-Code

Description

@Valyrian-Code

While working with fossology-python, I noticed that a few fields in Upload.__init__ are accidentally being wrapped in tuples because of trailing commas:

# fossology/obj.py
self.assignee = (assignee,)
self.assigneeDate = (assigneeDate,)
self.closeDate = (closingDate,)

These seem intended to be plain assignments instead.

Impact

This causes the attributes to have tuple types unexpectedly:

upload.assignee
# ('username',)

instead of:

'username'

It also affects truthiness checks:

assignee = None
print(bool((assignee,)))  # True

so code like:

if upload.assignee:

behaves incorrectly when the API returns None.

Minimal reproduction

from fossology.obj import Upload

u = Upload(
    folderid=1,
    foldername="test",
    id=1,
    description="",
    uploadname="foo",
    uploaddate="2024-01-01",
    assignee=None,
    hash={"sha1": "", "md5": "", "sha256": "", "size": 0},
)

print(type(u.assignee))
print(u.assignee)
print(bool(u.assignee))

Current output:

<class 'tuple'>
(None,)
True

Expected:

<class 'NoneType'>
None
False

Proposed fix

self.assignee = assignee
self.assigneeDate = assigneeDate
self.closeDate = closingDate

Environment:

  • fossology-python: 3.5.0
  • Python: 3.10+

gif

I’d like to work on this fix and open a PR for it, if that sounds good. 🧃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions