-
Notifications
You must be signed in to change notification settings - Fork 0
CodeQL fixes and minor refactoring #126
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
Pull Request Test Coverage Report for Build 19927157305Details
💛 - Coveralls |
|
|
||
|
|
||
| class AimsVibrations(Vibrations, AimsGeometry): # pyright: ignore | ||
| class AimsVibrations(Vibrations, AimsGeometry): |
|
|
||
|
|
||
| class VaspVibrations(Vibrations, VaspGeometry): # pyright: ignore | ||
| class VaspVibrations(Vibrations, VaspGeometry): |
| # for i, d in enumerate(edges[0]): | ||
| # self.settings["edge"].append([d, *list(edges[1][i, :])]) |
| # if len(self.type) > 0: | ||
| # text += "output cube " + self.type + "\n" | ||
| # else: | ||
| # warn("No cube type specified", stacklevel=2) | ||
| # text += "output cube" + "CUBETYPE" + "\n" | ||
|
|
||
| # for key, values in self.settings.items(): | ||
| # for v in values: | ||
| # text += "cube " + key + " " | ||
| # if key in self.parsing_functions: | ||
| # text += self.parsing_functions[key][1](v) + "\n" | ||
| # else: | ||
| # print(v) | ||
| # text += v + "\n" |
| def _supported_files(self) -> dict: | ||
| return {"arbitrary_format": ".arb_format"} | ||
|
|
||
| def dummy_method() -> None: |
|
|
||
| @pytest.fixture(scope="session") | ||
| def aims_calc_dir(run_aims, cwd) -> Generator[str, None, None] | str: # noqa: ANN001 | ||
| def aims_calc_dir(run_aims: bool, cwd: Path) -> Generator[str, None, None] | str: |
|
|
||
| __name__: str | ||
|
|
||
| def __call__(self, *args: Any, **kwargs: Any) -> Any: ... |
| output_file: str = "aims.out", | ||
| calc_dir: str = "./", | ||
| force: bool = False, | ||
| ) -> Decorator: ... |
| output_file: str = "aims.out", | ||
| calc_dir: str = "./", | ||
| force: bool = False, | ||
| ) -> Wrapper: ... |
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 addresses CodeQL findings and performs minor refactoring across the codebase. The changes focus on improving type safety by removing pyright ignore comments, modernizing file handling with pathlib, and cleaning up unused code.
Key changes include:
- Improved type annotations with Protocol and @overload patterns for better decorator typing
- Removed pyright ignore comments by fixing underlying type issues
- Modernized file path handling using pathlib.Path instead of os.path
- Updated dependencies (ipython 9.7.0→9.8.0, loro 1.8.2→1.10.0, marimo 0.18.1→0.18.2, narwhals 2.12.0→2.13.0)
- Cleaned up unused/unreachable code and dead logic branches
- Fixed several spelling errors in comments and docstrings
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Dependency version updates for ipython, loro, marimo, and narwhals packages |
| tests/test_utils.py | Refactored to use pathlib.Path and updated docstrings |
| tests/test_benchmarking.py | Added pytest.mark.skip decorator and TODO placeholder |
| tests/test_base.py | Added noqa comments and dummy methods to satisfy CodeQL checks |
| tests/conftest.py | Added type hints and corrected spelling in comments |
| dfttoolkit/vibrations.py | Removed pyright ignore comments throughout, but introduced incorrect type changes for time_step parameters |
| dfttoolkit/utils/run_utils.py | Added Protocol and overload for better decorator type safety |
| dfttoolkit/utils/periodic_table.py | Changed classproperty parameter names from cls to self (incorrect) |
| dfttoolkit/parameters.py | Simplified lambda expressions and commented out NotImplementedError code blocks |
| dfttoolkit/output.py | Refactored control flow and updated return type annotations |
| dfttoolkit/geometry.py | Removed unused variable assignments and function parameters |
| dfttoolkit/cube.py | Removed unused method with NotImplementedError |
| dfttoolkit/benchmarking.py | Changed from inheritance to composition pattern for AimsOutput |
| dfttoolkit/base.py | Fixed spelling in comment (file type → filetype) |
Comments suppressed due to low confidence (1)
tests/test_base.py:168
- Normal methods should have at least one parameter (the first of which should be 'self').
def dummy_method() -> None:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| velocities: npt.NDArray[np.float64], | ||
| index_pair: tuple, | ||
| time_step: float, | ||
| time_step: int, |
Copilot
AI
Dec 4, 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.
Changing time_step from float to int is likely incorrect. Time steps in physics simulations are typically floating-point values (e.g., 0.5 fs, 1.0 fs). The docstring on line 578 even says "time_step : float". This type change appears to be a mistake and could cause type errors when passing actual time step values.
| time_step: int, | |
| time_step: float, |
| index: npt.NDArray, | ||
| velocities_proj: npt.NDArray, | ||
| time_step: float, | ||
| time_step: int, |
Copilot
AI
Dec 4, 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.
Changing time_step from float to int is likely incorrect. Time steps in physics simulations are typically floating-point values (e.g., 0.5 fs, 1.0 fs). This type change appears to be a mistake and could cause type errors when passing actual time step values.
| time_step: int, | |
| time_step: float, |
| dict[str, npt.NDArray[np.int64 | np.float64]], | ||
| dict[str, npt.NDArray[np.int64 | np.float64]], | ||
| ] | ||
| | None |
Copilot
AI
Dec 4, 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.
Adding | None to the return type annotation is incorrect. The function always returns a value (either a dict or a tuple of dicts) after the refactoring. The else branch on lines 1359-1373 ensures all code paths return a value, so None should not be in the return type.
| | None |
|
|
||
| @classproperty | ||
| def elements(cls) -> dict[str, Element]: # noqa: N805 | ||
| def elements(self) -> dict[str, Element]: |
Copilot
AI
Dec 4, 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.
The parameter name should be cls not self for a classproperty. While classproperty might handle this internally, using self for a class-level property is misleading and violates Python conventions. The original cls parameter name on lines 87 and 99 in the same file shows the correct pattern.
|
|
||
| @classproperty | ||
| def element_symbols(cls) -> list[str]: # noqa: N805 | ||
| def element_symbols(self) -> list[str]: |
Copilot
AI
Dec 4, 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.
The parameter name should be cls not self for a classproperty. While classproperty might handle this internally, using self for a class-level property is misleading and violates Python conventions.
|
|
||
| @classproperty | ||
| def element_names(cls) -> list[str]: # noqa: N805 | ||
| def element_names(self) -> list[str]: |
Copilot
AI
Dec 4, 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.
The parameter name should be cls not self for a classproperty. While classproperty might handle this internally, using self for a class-level property is misleading and violates Python conventions.
| # self.settings["edge"] = [] | ||
| # for i, d in enumerate(edges[0]): | ||
| # self.settings["edge"].append([d, *list(edges[1][i, :])]) |
Copilot
AI
Dec 4, 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.
This comment appears to contain commented-out code.
| # self.settings["edge"] = [] | |
| # for i, d in enumerate(edges[0]): | |
| # self.settings["edge"].append([d, *list(edges[1][i, :])]) |
| # text = "" | ||
| # if len(self.type) > 0: | ||
| # text += "output cube " + self.type + "\n" | ||
| # else: | ||
| # warn("No cube type specified", stacklevel=2) | ||
| # text += "output cube" + "CUBETYPE" + "\n" | ||
|
|
||
| # for key, values in self.settings.items(): | ||
| # for v in values: | ||
| # text += "cube " + key + " " | ||
| # if key in self.parsing_functions: | ||
| # text += self.parsing_functions[key][1](v) + "\n" | ||
| # else: | ||
| # print(v) | ||
| # text += v + "\n" | ||
|
|
||
| # return text |
Copilot
AI
Dec 4, 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.
This comment appears to contain commented-out code.
| # text = "" | |
| # if len(self.type) > 0: | |
| # text += "output cube " + self.type + "\n" | |
| # else: | |
| # warn("No cube type specified", stacklevel=2) | |
| # text += "output cube" + "CUBETYPE" + "\n" | |
| # for key, values in self.settings.items(): | |
| # for v in values: | |
| # text += "cube " + key + " " | |
| # if key in self.parsing_functions: | |
| # text += self.parsing_functions[key][1](v) + "\n" | |
| # else: | |
| # print(v) | |
| # text += v + "\n" | |
| # return text |
|
|
||
|
|
||
| class AimsVibrations(Vibrations, AimsGeometry): # pyright: ignore | ||
| class AimsVibrations(Vibrations, AimsGeometry): |
Copilot
AI
Dec 4, 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.
Base classes have conflicting values for attribute 'get_instance_of_other_type': Function get_instance_of_other_type and Function get_instance_of_other_type.
|
|
||
|
|
||
| class VaspVibrations(Vibrations, VaspGeometry): # pyright: ignore | ||
| class VaspVibrations(Vibrations, VaspGeometry): |
Copilot
AI
Dec 4, 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.
Base classes have conflicting values for attribute 'get_instance_of_other_type': Function get_instance_of_other_type and Function get_instance_of_other_type.
No description provided.