UCLH-Foundry / PIXL

PIXL Image eXtraction Laboratory
Apache License 2.0
8 stars 0 forks source link

Private tag `UCLHPIXLProjectName` should always be of python type `str`, not `bytes` #363

Open jeremyestein opened 4 months ago

jeremyestein commented 4 months ago

Definition of Done / Acceptance Criteria

Details and Comments

I only noticed this recently, after the tag got introduced. I reckon it should be easily fixable since we have full control over the use of that tag.

This code snippet illustrates the problem

            if isinstance(private_tag.value, bytes):
                # Allow this for the time being, until it has been investigated
                logging.error(f"{private_tag.value} should be of type str, but is of type bytes")
                assert private_tag.value.decode() == TestFtpsUpload.project_slug
            else:
                assert private_tag.value == TestFtpsUpload.project_slug

similarly:

    if isinstance(raw_slug, bytes):
        logger.debug(f"Bytes slug {raw_slug!r}")
        slug = raw_slug.decode("utf-8").strip()
    else:
        logger.debug(f"String slug '{raw_slug}'")
        slug = raw_slug