Skip to content

Handle NoneType in MirrorPath.from_s3_key() #20

@TrevorBurgoyne

Description

@TrevorBurgoyne

Since MirrorPath.from_s3_key() uses str.removesuffix(), it breaks when a non-str is passed. Checking for type would be nifty to save headaches.

Error when calling MirrorPath.from_s3_key(None)

File "C:\Users\Trevor\py-rogue-detection\ddb_tracking\grd_structure.py", line 122, in from_json
 rogue_labels=MirrorPath.from_s3_key(json_dict["rogue_labels"]),
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Trevor\miniconda3\envs\rogue-venv\Lib\site-packages\S3MP\mirror_path.py", line 50, in from_s3_key
 s3_key = s3_key.removesuffix('/')
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'removesuffix'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions