-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: first iteration of fixing mypy complaints #59
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request updates the GitHub Actions workflow by adding a Mypy type-checking step to the quality-control job. In the codebase, several files are modified to enhance type annotations and clarify method signatures. The Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)`**/*.py`: Do not try to improve formatting. Do not suggest type annotations for functions that are defined inside of functions or methods. Do not suggest type annotation of the `s...
🧬 Code Definitions (1)src/snakemake_interface_common/plugin_registry/plugin.py (3)
🪛 Ruff (0.8.2)src/snakemake_interface_common/plugin_registry/plugin.py271-271: Use (E721) 🔇 Additional comments (23)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/snakemake_interface_common/settings.py (2)
100-104
: Provide a custom error message for invalid choices.Relying on
KeyError
may produce a less informative error. Consider raising a more descriptive exception, for example:- return cls[choice.replace("-", "_").upper()] + try: + return cls[choice.replace("-", "_").upper()] + except KeyError: + raise ValueError(f"Invalid choice: {choice}. Must be one of {cls.choices()}.")
105-118
: Consider adding dedicated tests for the new settings enumeration.Unit tests can verify that parsing choices, skipping members, and generating string representations behave as intended. Let me know if you need help creating such tests or if you’d like me to open a new issue tracking this task.
.github/workflows/test.yml (1)
39-42
: Consider uncommenting the Mypy stepSince this PR is specifically focused on fixing mypy complaints, it would be beneficial to enable the type checking step in the workflow to verify that all issues have been resolved.
- # - name: Mypy - # if: always() - # run: | - # pixi run --environment dev type-check + - name: Mypy + if: always() + run: | + pixi run --environment dev type-check
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
pixi.lock
is excluded by!**/*.lock
pyproject.toml
is excluded by!pyproject.toml
📒 Files selected for processing (14)
.gitattributes
(1 hunks).github/workflows/release-please.yml
(1 hunks).github/workflows/test.yml
(1 hunks).gitignore
(1 hunks)snakemake_interface_common/settings.py
(0 hunks)src/snakemake_interface_common/exceptions.py
(4 hunks)src/snakemake_interface_common/logging.py
(1 hunks)src/snakemake_interface_common/plugin_registry/__init__.py
(5 hunks)src/snakemake_interface_common/plugin_registry/attribute_types.py
(1 hunks)src/snakemake_interface_common/plugin_registry/plugin.py
(13 hunks)src/snakemake_interface_common/plugin_registry/tests.py
(2 hunks)src/snakemake_interface_common/rules.py
(1 hunks)src/snakemake_interface_common/settings.py
(1 hunks)src/snakemake_interface_common/utils.py
(5 hunks)
💤 Files with no reviewable changes (1)
- snakemake_interface_common/settings.py
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.py`: Do not try to improve formatting. Do not suggest ...
**/*.py
: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theself
argument of methods.
Do not suggest type annotation of thecls
argument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturn
statement.
src/snakemake_interface_common/logging.py
src/snakemake_interface_common/settings.py
src/snakemake_interface_common/exceptions.py
src/snakemake_interface_common/plugin_registry/attribute_types.py
src/snakemake_interface_common/utils.py
src/snakemake_interface_common/rules.py
src/snakemake_interface_common/plugin_registry/tests.py
src/snakemake_interface_common/plugin_registry/__init__.py
src/snakemake_interface_common/plugin_registry/plugin.py
🪛 Ruff (0.8.2)
src/snakemake_interface_common/plugin_registry/plugin.py
256-256: Use is
and is not
for type comparisons, or isinstance()
for isinstance checks
(E721)
🔇 Additional comments (61)
.gitattributes (1)
1-2
: Good practice for lock files.Defining
pixi.lock
as a binary file and marking it as generated ensures merge conflicts are avoided and that the file is treated correctly by GitHub’s linguist. This approach is well-aligned with standard practices for lock files..gitignore (1)
162-165
: Reevaluate ignoringpoetry.lock
.It’s generally recommended to commit
poetry.lock
for reproducible builds, especially for distributed teams. Please verify that ignoringpoetry.lock
is indeed desired. The additions for ignoring.pixi
and*.egg-info
are standard and look good.src/snakemake_interface_common/logging.py (2)
5-9
: Effective use of TYPE_CHECKING.Placing imports under
if TYPE_CHECKING:
is a clean way to prevent circular dependencies while still providing type hints to static analyzers.
11-13
: Correct return type annotation.Specifying the return type as
"logging.Logger"
is appropriate to avoid runtime import issues and maintain clarity for mypy. This change looks good.src/snakemake_interface_common/settings.py (1)
1-99
: Comprehensive and well-documented enumeration base class.The structure and docstrings for
SettingsEnumBase
are thorough. The approach of handling both internal and external representations is clear, and the helper methods (_parse_choices_into
,all
, etc.) make the codebase more uniform and maintainable.src/snakemake_interface_common/plugin_registry/attribute_types.py (1)
23-23
: Type annotations properly added to methodsThe addition of return type annotations to
is_optional
,is_class
, andinto_required
methods improves type safety while maintaining functionality. The self-referential type annotation ininto_required
is correctly implemented.Also applies to: 27-27, 30-30
.github/workflows/release-please.yml (1)
25-44
: Workflow modernization looks goodThe transition from Poetry to Pixi for dependency management appears well-implemented. The updated GitHub actions, installation of Pixi with appropriate version specification, and modern PyPI publishing configuration with token-based authentication represent a good modernization of the CI pipeline.
src/snakemake_interface_common/rules.py (1)
7-7
:❓ Verification inconclusive
Type annotations added to abstract methods
The addition of return type annotations to the abstract methods in
RuleInterface
improves type safety. Note that ifsnakefile
previously returnedPath
objects, changing tostr
return type represents an API change that may require updates to dependent code.Also applies to: 11-11, 15-15
🏁 Script executed:
#!/bin/bash # Check if there are any uses of Path methods on the result of snakefile calls rg -p "\.snakefile\(\)" -A 3 -B 3 | rg "\.stem|\.suffix|\.parent|\.resolve|\.absolute"Length of output: 88
Abstract Method Type Annotations and Potential API Change
The
RuleInterface
methods now have explicit return type annotations, which improves type safety. Note that changing thesnakefile
method’s return type from (presumably) aPath
tostr
represents an API decision that could affect dependent code. Although a shell search for chained Path method calls onsnakefile
did not produce any results, please manually verify that no modules rely onsnakefile
returning aPath
.
- File:
src/snakemake_interface_common/rules.py
- Line 7:
def name(self) -> str: ...
- Line 11:
def lineno(self) -> int: ...
- Line 15:
def snakefile(self) -> str: ...
Please confirm that all dependent code has been updated accordingly.
src/snakemake_interface_common/exceptions.py (4)
8-8
: Class attributes properly typed with appropriate importsAdding explicit type annotations for class attributes
lineno
,snakefile
, andrule
with proper Optional types improves code clarity and type checking capabilities.Also applies to: 18-20
22-22
: Method signatures enhanced with type annotationsType annotations for method parameters and return types are now properly specified, improving type safety. The change from
Path
tostr
for thesnakefile
parameter type is consistent with the similar change inrules.py
.Also applies to: 44-44, 46-46, 66-66
35-37
: Proper handling of ExceptionGroup for Python 3.11+ compatibilityThe code correctly handles the Python 3.11+
ExceptionGroup
with a version check and noqa comment to avoid linting errors on earlier Python versions.
61-61
: Functionally equivalent tuple manipulationThe modified args manipulation using tuple conversion and list operations is functionally equivalent to the previous version but uses more modern Python syntax with f-strings.
.github/workflows/test.yml (5)
10-14
: Proper permission configuration addedAdding explicit permissions is a security best practice. By defining specific access scopes, you're following the principle of least privilege.
17-17
: Job name change appropriately reflects expanded responsibilitiesRenaming from "formatting" to "quality-control" better represents the job's full scope, which now includes formatting, linting, and potentially type checking.
21-28
: Updated tooling from Poetry to PixiThe migration from Poetry to Pixi as the package/environment manager is consistently implemented with appropriate version pinning.
30-38
: New formatting and linting steps addedThe Ruff formatting and linting steps are properly configured with the
--check
and--diff
flags to ensure code quality without automatically modifying files.
50-60
: Testing job updates follow the same patternThe testing job has been consistently updated to use Pixi in the same way as the quality-control job, maintaining a uniform approach across the workflow.
src/snakemake_interface_common/plugin_registry/tests.py (6)
17-17
: Improved abstract method signature with proper return typeThe method signature now includes a return type annotation and uses the ellipsis syntax on the same line, which is more concise and helps with static type checking.
20-20
: Improved abstract method signature with proper return typeThe method signature now includes a return type annotation and uses the ellipsis syntax on the same line, which is more concise and helps with static type checking.
23-23
: Improved abstract method signatureThe method signature now uses the ellipsis syntax on the same line, which is more concise and helps with static type checking.
26-26
: Improved abstract method signatureThe method signature now uses the ellipsis syntax on the same line, which is more concise and helps with static type checking.
29-29
: Improved abstract method signature with proper return typeThe method signature now includes a return type annotation and uses the ellipsis syntax on the same line, which is more concise and helps with static type checking.
43-45
: Improved assertion message formattingThe assertion message has been reformatted to span multiple lines for better readability while maintaining the same functionality.
src/snakemake_interface_common/utils.py (9)
5-5
: Added necessary type annotation importsAdded imports from the typing module to support the type annotations throughout the file, which is essential for mypy type checking.
8-8
: Added type annotations to not_iterable functionThe function now has proper type annotations, indicating it takes any value and returns a boolean, which improves type safety.
20-20
: Added type annotations to clean methodThe static method now has proper type annotations, indicating it takes an instance of Any type and a method name as a string, which improves type safety.
23-23
: Added type annotations to init methodThe method now has proper type annotations, indicating it takes a Callable and returns None, which improves type safety.
28-28
: Added type annotations to get methodThe method now has proper type annotations, indicating it takes an instance of Any type and an owner that is either a type or None, and returns Any, which improves type safety.
39-54
: Enhanced lutime function with type annotations and improved docstringThe function now has proper type annotations and a well-structured docstring with Parameters and Returns sections, improving both type safety and documentation.
69-69
: Added type annotations to fmt_time inner functionThe inner function now has proper type annotations, indicating it takes a float and returns a string, which improves type safety.
85-85
: Added type annotations to lchmod function (first definition)The function now has proper type annotations, indicating it takes a string path and an integer mode, and returns None, which improves type safety.
90-90
: Added type annotations to lchmod function (second definition)The function now has proper type annotations, indicating it takes a string path and an integer mode, and returns None, which improves type safety.
src/snakemake_interface_common/plugin_registry/__init__.py (11)
10-10
: Added typing importsAdded necessary imports from typing module, including TYPE_CHECKING for conditional import of ArgumentParser.
16-18
: Added conditional import for ArgumentParserUsing TYPE_CHECKING guard for the ArgumentParser import helps prevent circular imports at runtime while still providing type information for static type checkers.
24-24
: Added type annotation for plugins class attributeExplicitly typing the plugins dictionary improves type safety and helps static type checkers understand the structure of the data.
26-26
: Added return type annotation to new methodAdding the return type annotation clarifies that the method returns an instance of PluginRegistryBase, improving type safety.
31-31
: Added return type annotation to init methodAdding the return type annotation clarifies that the method returns None, improving type safety.
60-60
: Added return type annotation to register_cli_args methodAdding the return type annotation clarifies that the method returns None, improving type safety.
66-66
: Added return type annotation to collect_plugins methodAdding the return type annotation clarifies that the method returns None, improving type safety.
84-84
: Added return type annotation to register_plugin methodAdding the return type annotation clarifies that the method returns None, improving type safety.
99-99
: Added return type annotation to validate_plugin methodAdding the return type annotation clarifies that the method returns None, improving type safety.
127-127
: Improved abstract method signatureThe abstract method now uses the ellipsis syntax on the same line and includes a return type annotation, making it more concise and type-safe.
135-135
: Improved abstract method signatureThe abstract method now uses the ellipsis syntax on the same line and includes a return type annotation, making it more concise and type-safe.
src/snakemake_interface_common/plugin_registry/plugin.py (18)
8-8
: Appropriate import additionGood addition of the
Field
import fromdataclasses
, which is now used in type annotations throughout the file.
11-11
: Well-structured import expansionThe expanded imports from
typing
properly include all the types used throughout the file, improving code clarity and type safety.
20-21
: Good practice for conditional importUsing conditional imports with
TYPE_CHECKING
is a good practice to avoid circular imports while still providing proper type information to static type checkers.
30-30
: Improved return type annotationThe explicit return type annotation for
get_items_by_category
makes the method's contract clearer and improves type safety.
41-41
: Enhanced type safety for dictionaryThe updated type hint for
_inner
correctly allows forstr | None
as keys, which aligns with the actual usage in the code.
43-45
: Added return type for clarityAdding the
None
return type toregister_settings
explicitly indicates that the method doesn't return anything.
55-55
: Improved dictionary return typeThe updated return type for
get_field_settings
correctly reflects that keys can bestr | None
, matching the type of_inner
.
61-61
: Enhanced iterator typingThe explicit iterator return type for
__iter__
improves type safety and makes the method's contract clearer.
68-68
: Concise abstract property return typesThe abstract properties now use concise return type annotations, which improves readability while maintaining type safety.
Also applies to: 72-72, 76-76
82-82
: Added boolean return typeAdding the
bool
return type tohas_settings_cls
makes the method's contract clearer.
91-91
: Properly typed parameterAdding the
Field
type annotation to thefmt_default
parameter improves type safety.
117-117
: Explicit None return typeAdding the
None
return type toregister_cli_args
explicitly indicates that the method doesn't return anything.
176-177
: Improved type annotationsThe parameter type hint for
validate_settings
and the nested functionget_description
now have proper type annotations, enhancing type safety.
199-199
: Enhanced return type specificityThe return type for
get_settings
now correctly specifies eitherSettingsBase
orTaggedSettings
as possible return values.
215-215
: Clear function signature with tuple return typeAdding type hints to
get_name_and_value
improves readability and type safety, especially with the tuple return type.
221-222
: Properly typed dictionariesThe updated type hints for
kwargs_tagged
andkwargs_all
correctly reflect their structure and usage in the code.
236-238
: Well-typed function parametersAdding type hints to the
extract_values
function parameters and return type improves code clarity and type safety.
306-307
: Comprehensive type annotations for nested functionsAdding type hints to
_parse_type
and its nested functionapply_type
improves type safety and code clarity.
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.github/workflows/test.yml (3)
23-29
: Review: Install Pixi StepThe Pixi installation step is well configured with the specified version (
v0.42.1
), environment (dev
), and caching enabled. One minor nitpick: verify that the parameter nameenvironments
(plural) is intentionally used here, as subsequent command flags use the singular--environment
. Consistency here helps avoid potential confusion.
45-47
: Review: Collect QC StepThe "Collect QC" step provides a simple echo confirming that all quality control checks passed. For enhanced diagnostics in the future, consider integrating actual output collection from the previous steps.
53-59
: Review: Install Pixi in Testing JobThis step duplicates the Pixi installation from the quality-control job, using identical parameters. To reduce repetition and simplify maintenance, consider consolidating this configuration using YAML anchors or a reusable workflow component.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/test.yml
(1 hunks)
🔇 Additional comments (8)
.github/workflows/test.yml (8)
10-15
: Review: Permissions Block SetupThe new permissions block correctly grants read access for contents and write access for checks, issues, and pull-requests. This enhances the workflow's ability to interact with PR checks and issues. Please double-check that these permissions are strictly necessary and don’t inadvertently provide broader access than intended.
17-19
: Review: Job Naming and Environment SetupThe job has been successfully renamed to "quality-control" to better reflect its expanded role (formatting, linting, type-checking, etc.). The runner environment ("ubuntu-latest") is appropriately set.
21-21
: Review: Checkout Action UpdateThe use of
actions/checkout@v4
is a welcome upgrade that ensures improved performance and access to newer GitHub features.
30-34
: Review: Ruff Format CheckThe "Ruff Format" step is correctly set up with an
if: always()
condition and executes the formatting check using Pixi. This helps ensure that code style standards are enforced consistently.
35-39
: Review: Ruff Lint StepThis step uses Pixi to lint the code with a diff output, which is useful for quickly identifying improvements after formatting. Its configuration with
if: always()
is appropriate.
40-44
: Review: Mypy Type-Check StepIntegrating the mypy step with Pixi (
pixi run --environment dev type-check
) aligns with the PR objective to resolve type issues. The configuration appears correct.
51-52
: Review: Code Checkout in Testing JobThe testing job correctly checks out the repository using
actions/checkout@v4
, ensuring that the latest code is used during tests.
60-62
: Review: Run Tests CommandThe test command now leverages Pixi (
pixi run --environment dev test --show-capture=all -s -vv
), which is consistent with the new dependency setup. Ensure that the flags used (--show-capture=all -s -vv
) provide the desired verbosity and output for your test suite.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/test.yml (1)
44-46
: Collect Quality Control (QC) Message:
The "Collect QC" step simply echoes a confirmation message. While it currently serves as a placeholder, consider enhancing this step in the future with more detailed reporting or integration with your CI reporting tools if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/test.yml
(1 hunks).gitignore
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .gitignore
🔇 Additional comments (10)
.github/workflows/test.yml (10)
10-15
: Enhanced Permissions Configuration:
The addition of an explicit permissions section (withcontents: read
,checks: write
,issues: write
, andpull-requests: write
) is a positive change. It clearly outlines the minimal rights required for the workflow, aligning with the principle of least privilege.
17-19
: Job Renaming & Setup:
Renaming the job from a generic name to quality-control better reflects that this job now encompasses multiple quality assurance tasks (formatting, linting, and type-checking). The use ofruns-on: ubuntu-latest
is standard and appropriate.
20-22
: Checkout Action Update:
Updating the checkout action toactions/checkout@v4
ensures that the workflow benefits from the latest updates and security fixes. This is an excellent move toward keeping dependencies up to date.
23-28
: Introducing Pixi Installation:
Replacing the Poetry installation with Pixi viaprefix-dev/[email protected]
aligns with the repo’s shift toward improved type checking and dependency management. The provided inputs forenvironments: dev
andpixi-version: v0.42.1
are clear and consistent.
29-33
: Ruff Format Step Addition:
Adding the "Ruff Format" step using Pixi (pixi run --environment dev format --check
) integrates automated formatting into the CI pipeline. The use ofif: always()
guarantees execution regardless of previous step failures, which is useful for reporting purposes.
34-38
: Ruff Linting Integration:
The new "Ruff lint" step ensures that code style issues are flagged early. The use of--diff
provides clarity on the corrections needed, supporting a more efficient review process.
39-43
: Mypy Type-Check Step:
Running mypy through Pixi (pixi run --environment dev type-check
) directly addresses the mypy complaint resolutions. This clear separation of type checking boosts confidence in the type annotations across the repository.
47-51
: Testing Job – Checkout Consistency:
The testing job continues to useactions/checkout@v4
, ensuring that the codebase is checked out with the same updated version as in the quality-control job. This consistency is beneficial for maintainability.
52-57
: Pixi Setup in Testing Job:
The testing job now includes a Pixi installation step with identical environment settings (environments: dev
andpixi-version: v0.42.1
) as in the quality-control job. This uniformity helps maintain environment consistency across different stages.
58-60
: Test Execution with Pixi:
The test step uses Pixi for running tests (pixi run --environment dev test --show-capture=all -s -vv
), which aligns with the new dependency management approach. The inclusion of verbose flags (-s -vv
and--show-capture=all
) is helpful for debugging and ensuring complete output capture during test runs.
… safety and clarity
…se for improved clarity and type safety
5d29e35
to
ea66427
Compare
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/snakemake_interface_common/plugin_registry/plugin.py (1)
271-271
: Useis not
instead of!=
for direct type comparison.
For clarity and alignment with Python style guidelines (E721), compare type objects withis
oris not
:-elif thefield.type != str and isinstance(thefield.type, type): +elif thefield.type is not str and isinstance(thefield.type, type):🧰 Tools
🪛 Ruff (0.8.2)
271-271: Use
is
andis not
for type comparisons, orisinstance()
for isinstance checks(E721)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pyproject.toml
is excluded by!pyproject.toml
📒 Files selected for processing (9)
.github/workflows/test.yml
(1 hunks)src/snakemake_interface_common/exceptions.py
(4 hunks)src/snakemake_interface_common/logging.py
(1 hunks)src/snakemake_interface_common/plugin_registry/__init__.py
(5 hunks)src/snakemake_interface_common/plugin_registry/attribute_types.py
(1 hunks)src/snakemake_interface_common/plugin_registry/plugin.py
(13 hunks)src/snakemake_interface_common/rules.py
(1 hunks)src/snakemake_interface_common/settings.py
(1 hunks)src/snakemake_interface_common/utils.py
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
- .github/workflows/test.yml
- src/snakemake_interface_common/rules.py
- src/snakemake_interface_common/logging.py
- src/snakemake_interface_common/plugin_registry/attribute_types.py
- src/snakemake_interface_common/exceptions.py
- src/snakemake_interface_common/plugin_registry/init.py
- src/snakemake_interface_common/utils.py
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.py`: Do not try to improve formatting. Do not suggest type annotations for functions that are defined inside of functions or methods. Do not suggest type annotation of the `s...
**/*.py
: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theself
argument of methods.
Do not suggest type annotation of thecls
argument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturn
statement.
src/snakemake_interface_common/settings.py
src/snakemake_interface_common/plugin_registry/plugin.py
🧬 Code Definitions (1)
src/snakemake_interface_common/plugin_registry/plugin.py (3)
src/snakemake_interface_common/plugin_registry/__init__.py (1)
register_cli_args
(64-68)src/snakemake_interface_common/plugin_registry/tests.py (1)
validate_settings
(26-26)src/snakemake_interface_common/rules.py (1)
name
(7-7)
🪛 Ruff (0.8.2)
src/snakemake_interface_common/plugin_registry/plugin.py
271-271: Use is
and is not
for type comparisons, or isinstance()
for isinstance checks
(E721)
🔇 Additional comments (3)
src/snakemake_interface_common/settings.py (2)
10-64
: Comprehensive docstring improvements look good.
The updated docstrings provide clear guidance on usage and highlight each method’s purpose. This enhances readability and maintainability.
90-101
: Potential type mismatch inparse_choice
return type.
The_parse_choices_into
method castscls.parse_choice(choice)
toTSettingsEnumBase
, butparse_choice
is declared to return"SettingsEnumBase"
. Additionally, the docstring suggests it returnsTSettingsEnumBase
. For consistency, consider updating the return annotation to match your usage and docstring:- def parse_choice(cls, choice: str) -> "SettingsEnumBase": + def parse_choice(cls, choice: str) -> TSettingsEnumBase: """Converts a single string choice into an enum member.""" ...src/snakemake_interface_common/plugin_registry/plugin.py (1)
321-347
: Good handling of optional vs. non-optional types.
This_parse_type
logic carefully checks if a type istyping.Optional
or a single plain type, correctly raising errors for unsupported unions.🧰 Tools
🪛 Ruff (0.8.2)
326-332: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
NOTE: This PR depends on #58 to be merged first
This PR fixes all the mypy complaints within the repo
This allows future PRs to start addressing any discrepencies between the types annotated so far and all the concrete implementations throughout the
interface
pluginsSummary by CodeRabbit
SettingsEnumBase
class for better clarity.These behind-the-scenes improvements help ensure a smoother, more dependable experience for our users.