rapidsai / dependency-file-generator

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

fix: raise informative error if 'extras' key is missing for pyproject files #95

Closed jameslamb closed 5 months ago

jameslamb commented 5 months ago

Contributes to #87.

mypy caught some code that's treating File.extras as if it's unconditionally not None, when it actually can be None.

_rapids_dependency_file_generator.py:426: error: Argument "extras" to "make_dependency_file" has incompatible type "FileExtras | None"; expected "FileExtras"  [arg-type]

This fixes that by correcting some types hints and explicitly raising an error if a None makes it to the part of make_dependency_file() where that extras field is nedeed.

Prior to this change, given a dependencies.yaml like this:

files:
  beep_boop:
    output: pyproject
    includes:
      - run_deps
    pyproject_dir: .
dependencies:
  run_deps:
    common:
      - output_types: [pyproject]
        packages:
          - fsspec>=0.6.0

rapids-dependency-file-generator would raise an error like this:

Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'table'

As of this change, the error is more informative and requires less knowledge of the rapids-dependency-file-generator internals:

Traceback (most recent call last):
...
ValueError: The 'extras' field must be provided for the 'pyproject' file type.
GPUtester commented 5 months ago

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

The release is available on:

Your semantic-release bot :package::rocket: