Closed lang-m closed 5 months ago
PR Description updated to latest commit (https://github.com/ubermag/discretisedfield/commit/20b7dff831875f42077b3520eb9cebbaf38ba085)
⏱️ Estimated effort to review [1-5] | 3, because the PR includes a variety of changes across multiple configuration files and Python scripts. The changes involve updates to pre-commit hooks, removal of old linting configurations, and adjustments in testing configurations. Understanding the implications of these changes, especially in the context of continuous integration and code quality, requires a thorough review. |
🧪 Relevant tests | No |
🔍 Possible issues | Possible Bug: The change in `discretisedfield/field.py` modifies the behavior of the `_r_dim_mapping` method by removing the default return value of `None` for missing keys in the dictionary comprehension. This could lead to a `KeyError` if `reversed_mapping` does not contain a key found in `self.mesh.region.dims`. |
🔒 Security concerns | No |
relevant file | discretisedfield/field.py |
suggestion | Consider restoring the default value of `None` in the dictionary comprehension to avoid potential `KeyError`. This can be done by modifying the line to include a default return value when the key is not found in the `reversed_mapping`. [important] |
relevant line | return {dim: reversed_mapping.get(dim) for dim in self.mesh.region.dims} |
Category | Suggestions |
Bug |
Add a default value in dictionary lookup to prevent potential
___
**In the |
Enhancement |
Update the revision number in pre-commit configuration to the latest version.___ **Update therev version for the pre-commit/pre-commit-hooks to v4.5.0 to match the new version specified in the PR. This ensures that all hooks use the latest versions for consistency and to leverage any new features or bug fixes in the hooks.** [.pre-commit-config.yaml [5]](https://github.com/ubermag/discretisedfield/pull/525/files#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R5-R5) ```diff -rev: v4.4.0 +rev: v4.5.0 ``` |
Expand the list of ignored warnings in pytest configuration for clearer test outputs.___ **It's beneficial to specify a more comprehensive list of warnings to ignore in the pytestconfiguration to avoid common false positives and focus on significant warnings during testing.** [pyproject.toml [112-115]](https://github.com/ubermag/discretisedfield/pull/525/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R112-R115) ```diff filterwarnings = [ + "error", + "ignore:DeprecationWarning", + "ignore:UserWarning", + "ignore:((.|\n)*)Sentinel is not a public part of the traitlets API((.|\n)*)" +] ``` | |
Best practice |
Refine the pattern for omitting files in coverage configuration to improve accuracy.___ **Theomit configuration in [tool.coverage.run] should include more specific patterns to ensure that only test files are omitted from coverage reports, rather than excluding all files under the tests directory. This change helps in maintaining accurate test coverage metrics.** [pyproject.toml [73]](https://github.com/ubermag/discretisedfield/pull/525/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R73-R73) ```diff -omit = ["discretisedfield/tests/*"] +omit = ["discretisedfield/tests/**/*.py"] ``` |
Reintroduce the trailing whitespace hook for cleaner code.___ **Consider reintroducing thetrailing-whitespace hook in the pre-commit configuration. This hook is useful for maintaining clean code by automatically removing unnecessary trailing whitespaces, which are generally considered bad practice in many coding standards.** [.pre-commit-config.yaml [7-10]](https://github.com/ubermag/discretisedfield/pull/525/files#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R7-R10) ```diff hooks: + - id: trailing-whitespace ``` |
User description
Type
enhancement, bug_fix
Description
setup.cfg
as the project transitions to usingruff
for linting.pyproject.toml
to handle specific false positives and improve test configurations.Changes walkthrough
3 files
.pre-commit-config.yaml
Update and streamline pre-commit configurations
.pre-commit-config.yaml
pyproject.toml
Enhance Python project configurations
pyproject.toml
tool.coverage.run
andtool.pytest.ini_options
.tool.ruff
settings to handle notebook specific falsepositives.
setup.cfg
Remove flake8 configurations
setup.cfg - Removed all flake8 configurations.
1 files
field.py
Simplify dictionary comprehension in field.py
discretisedfield/field.py - Simplified dictionary comprehension in `_r_dim_mapping` property.
10 files
__init__.py
Minor formatting improvement in __init__.py
discretisedfield/__init__.py - Added a blank line for better code organization.
__init__.py
Minor formatting improvement in io/__init__.py
discretisedfield/io/__init__.py - Added a blank line for clarity.
ovf2vtk.py
Minor formatting improvement in ovf2vtk.py
discretisedfield/io/ovf2vtk.py - Added a blank line for clarity.
__init__.py
Minor formatting improvement in plotting/__init__.py
discretisedfield/plotting/__init__.py - Added a blank line for clarity.
hv.py
Minor formatting improvement in hv.py
discretisedfield/plotting/hv.py - Added a blank line for clarity.
k3d_field.py
Minor formatting improvement in k3d_field.py
discretisedfield/plotting/k3d_field.py - Added a blank line for clarity.
mpl.py
Minor formatting improvement in mpl.py
discretisedfield/plotting/mpl.py - Added a blank line for clarity.
mpl_field.py
Minor formatting improvement in mpl_field.py
discretisedfield/plotting/mpl_field.py - Added a blank line for clarity.
__init__.py
Minor formatting improvement in tools/__init__.py
discretisedfield/tools/__init__.py - Added a blank line for clarity.
tasks.py
Minor formatting improvement in tasks.py
tasks.py - Added a blank line for clarity.