-
Notifications
You must be signed in to change notification settings - Fork 15
feat(PDRIVE-687): add mypy-based pre-commit hook for SafeCmdString ty… #123
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
Open
hoberger-rh
wants to merge
1
commit into
RedHatInsights:main
Choose a base branch
from
hoberger-rh:PDRIVE-687
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [mypy] | ||
| python_version = 3.12 | ||
| check_untyped_defs = True | ||
| show_error_codes = True | ||
|
|
||
| # Only report SafeCmdString type errors | ||
| disable_error_code = assignment,var-annotated,no-untyped-def,return-value,import-untyped,no-any-return,attr-defined | ||
|
|
||
| # Ignore third-party modules without stubs | ||
| ignore_missing_imports = True | ||
|
|
||
| # Files to check | ||
| files = src/in_cluster_checks/ | ||
|
|
||
| [mypy-openshift_client.*] | ||
| ignore_missing_imports = True | ||
|
|
||
| [mypy-dateutil.*] | ||
| ignore_missing_imports = True | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ dev = [ | |
| "black>=24.1.1", | ||
| "flake8>=7.0.0", | ||
| "isort>=5.13.2", | ||
| "mypy>=1.0.0", | ||
| ] | ||
|
|
||
| [project.scripts] | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: RedHatInsights/incluster-checks
Length of output: 260
🌐 Web query:
mypy error code assignment return-value disable suppress incompatible assignment return type documentation💡 Result:
To suppress or disable specific mypy error codes, such as those related to assignment or return values, you can use inline comments or configuration file settings [1][2]. To suppress errors on a specific line, append an inline comment with the relevant error code in brackets [3]: # type: ignore[assignment] # type: ignore[return-value] Using specific codes is recommended over a bare # type: ignore, as it prevents you from accidentally silencing other, unrelated errors on the same line [4][3]. To identify the exact error code being triggered, you can enable them in your output by setting show_error_codes = True in your mypy configuration file (mypy.ini or pyproject.toml) [4]. If you wish to disable an error code for an entire file, you can place a special comment at the top of the file [1][5]: # mypy: disable-error-code="assignment, return-value" You can also manage error codes globally or per-module via your configuration file [1][2]: [mypy] disable_error_code = assignment, return-value [mypy-my_module.*] disable_error_code = assignment For reference, common error codes include: - [assignment]: Used for incompatible types in assignment [6]. - [return-value]: Used when a function returns a value incompatible with its return type annotation [6]. - [method-assign]: A subcode of [assignment] that triggers when an assignment target is a method [6]. If an error code is a subcode of a broader category, ignoring the broader code (e.g., [assignment]) will typically suppress the narrower subcode as well [1][3].
Citations:
🏁 Script executed:
Repository: RedHatInsights/incluster-checks
Length of output: 50387
🏁 Script executed:
Repository: RedHatInsights/incluster-checks
Length of output: 46068
Keep
assignmentandreturn-valueenabled forSafeCmdStringThese global suppressions also hide plain
strflowing throughSafeCmdString-annotated assignments and returns. Narrow the suppression instead of disabling those codes project-wide.🤖 Prompt for AI Agents