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

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

Merged
merged 1 commit into from
May 14, 2024

Conversation

jameslamb
Copy link
Member

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.

@jameslamb jameslamb added bug Something isn't working non-breaking Introduces a non-breaking change labels May 14, 2024
@jameslamb jameslamb merged commit 1ff87f5 into rapidsai:main May 14, 2024
4 checks passed
@jameslamb jameslamb deleted the mypy/pyproject-extras branch May 14, 2024 22:20
GPUtester pushed a commit that referenced this pull request May 14, 2024
## [1.13.8](v1.13.7...v1.13.8) (2024-05-14)

### Bug Fixes

* raise informative error if 'extras' key is missing for pyproject files ([#95](#95)) ([1ff87f5](1ff87f5))
@GPUtester
Copy link

🎉 This PR is included in version 1.13.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

difyrrwrzd added a commit to difyrrwrzd/dependency-file-generator that referenced this pull request Aug 10, 2024
## [1.13.8](rapidsai/dependency-file-generator@v1.13.7...v1.13.8) (2024-05-14)

### Bug Fixes

* raise informative error if 'extras' key is missing for pyproject files ([#95](rapidsai/dependency-file-generator#95)) ([8df7b8c](rapidsai/dependency-file-generator@8df7b8c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Introduces a non-breaking change released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants