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

Handle NoneType in MirrorPath.from_s3_key() #20

Open
TrevorBurgoyne opened this issue May 15, 2023 · 2 comments
Open

Handle NoneType in MirrorPath.from_s3_key() #20

TrevorBurgoyne opened this issue May 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@TrevorBurgoyne
Copy link
Member

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'
@joshua-dean joshua-dean added the bug Something isn't working label May 15, 2023
@joshua-dean
Copy link
Collaborator

Would preferred behavior be raise a warning and default to "", or something else?
If there's not any sort of default behavior, it seems like this would just move the AttributeError upstream.

We could also set the behavior via the configuration.

@TrevorBurgoyne
Copy link
Member Author

Raising a warning and returning None or "" seems good. In my particular use case returning None is what I ended up doing anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants