Skip to content

feat: add mypy plugin options to handle missing paramters for a task #428

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

Merged
merged 3 commits into from
Apr 26, 2025

Conversation

hiro-o918
Copy link
Contributor

@hiro-o918 hiro-o918 commented Jan 31, 2025

Background

In this discussion, I initially omitted handling errors for missing parameters in the task constructor because luigi.Config allows implicit parameters, making it difficult to validate them on linting

However, I occasionally forget to pass required parameters to tasks, leading to runtime errors when executing the pipeline.

What

This PR introduces an option for gokart mypy to raise an error when a task constructor is called without all required parameters.

Users can configure mypy to allow implicit parameter passing if needed in their project.

Copy link
Collaborator

@hirosassa hirosassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

module = ["pandas.*", "apscheduler.*", "dill.*", "boto3.*", "testfixtures.*", "luigi.*"]

[tool.gokart-mypy]
error_on_missing_parameters = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is a little long. And the name of mypy is something like disallow- or ignore-. Therefore, I think disallow_missing_parameters is preferable. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the param name

gokart/mypy.py Outdated
config = cls._parse_toml(config_file)
gokart_plugin_config = config.get('tool', {}).get('gokart-mypy', {})

error_on_missing_parameters = gokart_plugin_config.get('error_on_missing_parameters', False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think parameter name should be FINAL variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduce Enum for parameters

@hiro-o918 hiro-o918 force-pushed the feature/missing-parameters branch 4 times, most recently from 857b40d to f8432e7 Compare March 24, 2025 08:03
@hiro-o918 hiro-o918 requested a review from kitagry March 24, 2025 08:06
Copy link
Member

@kitagry kitagry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hiro-o918 Sorry for the late review. Could you add documentation?

@hiro-o918 hiro-o918 force-pushed the feature/missing-parameters branch from 9af5f47 to ddf8e6a Compare April 25, 2025 01:33
@hiro-o918
Copy link
Contributor Author

Sorry for late response, I added docs
ddf8e6a

@hiro-o918 hiro-o918 requested a review from kitagry April 25, 2025 04:43
@hiro-o918 hiro-o918 force-pushed the feature/missing-parameters branch from ddf8e6a to d89dcb3 Compare April 25, 2025 04:43
@kitagry
Copy link
Member

kitagry commented Apr 26, 2025

Thank you!!

@kitagry kitagry merged commit d94754c into master Apr 26, 2025
8 checks passed
@kitagry kitagry deleted the feature/missing-parameters branch April 26, 2025 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants