ansible / ansible-runner

A tool and python library that helps when interfacing with Ansible directly or as part of another system whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal is to provide a stable and consistent interface abstraction to Ansible.
Other
968 stars 356 forks source link

Refactor and test dump_artifact() method #1296

Closed Shrews closed 1 year ago

Shrews commented 1 year ago

The mypy linter currently complains about the dump_artifact() method once typing is added to it. This is because there exists a code branch where hexdigest() could be called on a variable with a None type. The code logic was also overly complex. This is simplified by reorganizing it slightly, and not allowing for the filename parameter to be None (we never pass it that value except in a unit test). Some unit tests are added to make sure it functions as expected.

I think we could simplify this code even further:

I didn't make those other changes, though, since I wanted to leave the current functionality intact until a later date, and I only want to fix the linting issue in this PR.