Skip to content

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

Merged
kitagry merged 3 commits intomasterfrom
feature/missing-parameters
Apr 26, 2025
Merged

feat: add mypy plugin options to handle missing paramters for a task#428
kitagry merged 3 commits intomasterfrom
feature/missing-parameters

Conversation

@hiro-o918
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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