rapidsai / dependency-file-generator

https://pypi.org/project/rapids-dependency-file-generator/
Apache License 2.0
15 stars 13 forks source link

fix: fix return type hint for dedupe() #90

Closed jameslamb closed 5 months ago

jameslamb commented 5 months ago

Contributes to #87.

rapids-dependency-file-generator handles deduplicating the sets of dependencies provided to it, including pip: lists for conda environments.

This PR modifies the logic the function does that in the following ways:

This fixes these errors found by mypy:

src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:65: error: Argument 1 to "append" of "list" has incompatible type "dict[str, list[str]]"; expected "str"  [arg-type]
src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:66: error: Incompatible return value type (got "list[str]", expected "list[str | dict[str, str]]")  [return-value]
src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:66: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:66: note: Consider using "Sequence" instead, which is covariant
src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:66: note: Perhaps you need a type annotation for "deduped"? Suggestion: "list[str | dict[str, str]]"
src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py:425: error: Argument "dependencies" to "make_dependency_file" has incompatible type "list[str | dict[str, str]]"; expected "list[str | dict[str, list[str]]]"  [arg-type]

How I tested this

Confirmed that this behavior is covered by existing unit tests (and added one more condition there for completeness).

Ran the following to confirm that some of the mypy issues had been resolved:

mypy \
    --ignore-missing-imports \
    --explicit-package-bases \
    ./src
GPUtester commented 5 months ago

:tada: This PR is included in version 1.13.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket: