-
Notifications
You must be signed in to change notification settings - Fork 1
Fix all mypy errors, add ignores where needed #88
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
Conversation
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.
Pull Request Overview
This PR fixes all mypy errors by refactoring certain import paths, updating type hints, and adding or removing type ignore comments where needed. Key changes include:
- Adjusting import statements for Trainer and TrainingArguments across training scripts.
- Updating type hint usage and adding explicit type ignores in model modules and utility functions.
- Revising tensor initializations and padding methods to improve type safety.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/training/run_atom3d.py | Updated import paths and added type ignores to resolve type-checking issues. |
| scripts/training/pretrain_s2ef.py | Similar import refactors and ignore annotations to fix mypy errors. |
| atomgen/models/tokengt.py | Revised transformer configuration initialization with adjusted type ignores. |
| atomgen/models/schnet.py | Removed unnecessary type ignores and updated config assignment. |
| atomgen/models/modeling_atomformer.py | Changed loss initialization and added type ignores to better align with types. |
| atomgen/models/configuration_atomformer.py | Removed extraneous type ignores in configuration initialization. |
| atomgen/data/utils.py | Added tuple checks and explicit type casts for metric computations. |
| atomgen/data/tokenizer.py | Improved type hints and adjusted pad functions with more specific annotations. |
| atomgen/data/data_collator.py | Refactored tokenizer import and added type ignore annotations on assignments. |
Comments suppressed due to low confidence (1)
atomgen/models/schnet.py:137
- Verify that suppressing type checks for the config_class assignment is necessary; if possible, update type definitions to obviate the need for an ignore comment.
config_class = SchNetConfig # type: ignore[assignment]
|
|
||
| # Initialize trainer | ||
| trainer = Trainer( | ||
| trainer = Trainer( # type: ignore[no-untyped-call] |
Copilot
AI
May 27, 2025
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.
Using 'type: ignore' suppresses type checking for the Trainer instantiation; consider enhancing or contributing improved type stubs for the transformers library to reduce reliance on ignores.
| loss_coords = loss_fct(coords_pred, labels_coords) | ||
|
|
||
| loss = torch.Tensor(0).to(coords.device) | ||
| loss = torch.tensor(0.0).to(coords.device) |
Copilot
AI
May 27, 2025
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.
Replacing torch.Tensor(0) with torch.tensor(0.0) makes the intent clear by explicitly creating a float tensor, improving readability and type safety.
| loss = torch.tensor(0.0).to(coords.device) | |
| loss = torch.tensor(0.0, dtype=torch.float32).to(coords.device) |
| ): | ||
| encoded_inputs = self.pad_coords( | ||
| encoded_inputs, | ||
| encoded_inputs = self.pad_coords( # type: ignore[assignment] |
Copilot
AI
May 27, 2025
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.
[nitpick] Consider reviewing the need for a type ignore on this assignment in pad_coords to ensure that the underlying types are correctly handled and to maintain long-term code safety.
PR Type
Fixes all mypy errors