refactor: Completed type hints and attribute annotations#18
Open
ICasciuc wants to merge 2 commits intoPOSidorov:devfrom
Open
refactor: Completed type hints and attribute annotations#18ICasciuc wants to merge 2 commits intoPOSidorov:devfrom
ICasciuc wants to merge 2 commits intoPOSidorov:devfrom
Conversation
… optimizer, CLI, and estimator modules. # Merge Request Notes **Summary** - Completed type hints and attribute annotations across chem, optimizer, CLI, and estimator modules. - Removed `from __future__ import annotations` across the repo as requested and reformatted tests. - Added `.isort.cfg` (black profile) to keep isort/black consistent. - Small maintenance fixes for pandas 3 compatibility, clearer errors, and unused imports. **Core Library** - `doptools/chem/chem_features.py`: completed type hints (signatures and attributes), added `DescriptorLike` protocol, typed feature collections, and cleaned up typing casts. Also replaced `DataFrame.applymap` with `DataFrame.map` for pandas 3 compatibility and added an explicit `ValueError` for unknown task types in `calculate_scores`. - `doptools/chem/coloratom.py`: added file-level lint/type suppressions to avoid legacy issues during typing/linting. - `doptools/chem/utils.py`: removed an unused local to satisfy lint. **Optimizer** - `doptools/optimizer/optimizer.py`: completed type hints and clarified internal variable typing; no logic changes. - `doptools/optimizer/preparer.py`: completed type hints, narrowed a broad `except` to `Exception`, and cleaned up messaging/formatting. - `doptools/optimizer/config.py`: type hints and `# noqa` on unused exported imports/constants. - `doptools/optimizer/__init__.py`: added `# noqa` to star exports. **CLI** - `doptools/cli/launch_optimizer.py`: replaced star imports with explicit imports and added type hints. - `doptools/cli/launch_preparer.py`: added type hints and file-level flake8 suppression to avoid heavy rewraps. - `doptools/cli/plotter.py`: added type hints. - `doptools/cli/ensemble_model_rebuilding.py`: added type hints and file-level flake8 suppression. - `doptools/cli/rebuilder.py`: added type hints and a `rebuild_from_file` stub that raises `NotImplementedError` with guidance. - `doptools/cli/__init__.py`: added `# noqa` to star exports. **Estimators** - `doptools/estimators/ad_estimators.py`: completed type hints; preserved the `BoudingBox` typo for tests and suppressed the resulting name error in typing/lint. - `doptools/estimators/consensus.py`: completed type hints. **Package Exports** - `doptools/__init__.py`, `doptools/chem/__init__.py`, `doptools/optimizer/__init__.py`, `doptools/cli/__init__.py`: added `# noqa: F401,F403` to allow star exports. **Tests** - Removed `from __future__ import annotations` from tests and reflowed with black where needed. - `tests/conftest.py` and `tests/data/chem/generate_expected.py`: `yaml` import marked `# type: ignore[import-untyped]`. - `tests/cli/test_launch_preparer.py`: typed `_DummyPool.mapped`. - `tests/estimators/test_ad_estimators.py`: removed unused pandas import. - `tests/chem/test_chem_features.py`: import reorder only. **Other** - `setup.py`: wrapped long description/classifier strings. - `.isort.cfg`: new config aligning isort with black. **Typing/Lint Suppressions & Ignores** - `doptools/chem/coloratom.py`: `# mypy: ignore-errors`, `# flake8: noqa`. - `doptools/cli/ensemble_model_rebuilding.py`: `# flake8: noqa`. - `doptools/cli/launch_preparer.py`: `# flake8: noqa`. - `doptools/estimators/ad_estimators.py`: `# type: ignore[name-defined]` and `# noqa: F821` for `BoudingBox`. - `doptools/optimizer/config.py`: `# noqa: F401` on exported imports, `# noqa: E501` on long descriptor strings. - `doptools/__init__.py`, `doptools/chem/__init__.py`, `doptools/optimizer/__init__.py`, `doptools/cli/__init__.py`: `# noqa: F401,F403` for star exports. - `tests/conftest.py`, `tests/data/chem/generate_expected.py`: `# type: ignore[import-untyped]` for `yaml`. **Non-Typing Behavior Changes** - `doptools/chem/chem_features.py`: `ChythonLinear.transform` now uses `DataFrame.map` instead of `applymap` (pandas 3 compatibility). - `doptools/chem/chem_features.py`: `calculate_scores` now raises `ValueError` for unknown task types (previously fell through). - `doptools/cli/rebuilder.py`: `rebuild_from_file` now explicitly raises `NotImplementedError`. **Tests & Lint** - `pre-commit run --all-files` - `python -m pytest -q -p no:cacheprovider` (99 passed, 3 skipped) **Files Changed** - `.isort.cfg` - `doptools/__init__.py` - `doptools/chem/__init__.py` - `doptools/chem/chem_features.py` - `doptools/chem/coloratom.py` - `doptools/chem/utils.py` - `doptools/cli/__init__.py` - `doptools/cli/ensemble_model_rebuilding.py` - `doptools/cli/launch_optimizer.py` - `doptools/cli/launch_preparer.py` - `doptools/cli/plotter.py` - `doptools/cli/rebuilder.py` - `doptools/estimators/ad_estimators.py` - `doptools/estimators/consensus.py` - `doptools/optimizer/__init__.py` - `doptools/optimizer/config.py` - `doptools/optimizer/optimizer.py` - `doptools/optimizer/preparer.py` - `setup.py` - `tests/chem/test_chem_features.py` - `tests/chem/test_coloratom.py` - `tests/chem/test_solvents.py` - `tests/chem/test_utils.py` - `tests/cli/test_ensemble_model_rebuilding.py` - `tests/cli/test_launch_optimizer.py` - `tests/cli/test_launch_preparer.py` - `tests/cli/test_plotter.py` - `tests/cli/test_rebuilder.py` - `tests/conftest.py` - `tests/data/chem/generate_expected.py` - `tests/estimators/test_ad_estimators.py` - `tests/estimators/test_consensus.py` - `tests/optimizer/test_config.py` - `tests/optimizer/test_optimizer.py` - `tests/optimizer/test_preparer.py` - `tests/optimizer/test_utils.py` - `MR_NOTES.md`
refactor: Completed type hints and attribute annotations across chem,…
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
from __future__ import annotationsacross the repo as requested and reformatted tests..isort.cfg(black profile) to keep isort/black consistent.Core Library
doptools/chem/chem_features.py: completed type hints (signatures and attributes), addedDescriptorLikeprotocol, typed feature collections, and cleaned up typing casts. Also replacedDataFrame.applymapwithDataFrame.mapfor pandas 3 compatibility and added an explicitValueErrorfor unknown task types incalculate_scores.doptools/chem/coloratom.py: added file-level lint/type suppressions to avoid legacy issues during typing/linting.doptools/chem/utils.py: removed an unused local to satisfy lint.Optimizer
doptools/optimizer/optimizer.py: completed type hints and clarified internal variable typing; no logic changes. Fixed a bug for 'csv' in optimizer.py collect_data. (No args passed to index())doptools/optimizer/preparer.py: completed type hints, narrowed a broadexcepttoException, and cleaned up messaging/formatting.doptools/optimizer/config.py: type hints and# noqaon unused exported imports/constants.doptools/optimizer/__init__.py: added# noqato star exports.CLI
doptools/cli/launch_optimizer.py: replaced star imports with explicit imports and added type hints.doptools/cli/launch_preparer.py: added type hints and file-level flake8 suppression to avoid heavy rewraps.doptools/cli/plotter.py: added type hints.doptools/cli/ensemble_model_rebuilding.py: added type hints and file-level flake8 suppression.doptools/cli/rebuilder.py: added type hints and arebuild_from_filestub that raisesNotImplementedErrorwith guidance.doptools/cli/__init__.py: added# noqato star exports.Estimators
doptools/estimators/ad_estimators.py: completed type hints; preserved theBoudingBoxtypo for tests and suppressed the resulting name error in typing/lint.doptools/estimators/consensus.py: completed type hints.Package Exports
doptools/__init__.py,doptools/chem/__init__.py,doptools/optimizer/__init__.py,doptools/cli/__init__.py: added# noqa: F401,F403to allow star exports.Tests
from __future__ import annotationsfrom tests and reflowed with black where needed.tests/conftest.pyandtests/data/chem/generate_expected.py:yamlimport marked# type: ignore[import-untyped].tests/cli/test_launch_preparer.py: typed_DummyPool.mapped.tests/estimators/test_ad_estimators.py: removed unused pandas import.tests/chem/test_chem_features.py: import reorder only.Other
setup.py: wrapped long description/classifier strings..isort.cfg: new config aligning isort with black.Typing/Lint Suppressions & Ignores
doptools/chem/coloratom.py:# mypy: ignore-errors,# flake8: noqa.doptools/cli/ensemble_model_rebuilding.py:# flake8: noqa.doptools/cli/launch_preparer.py:# flake8: noqa.doptools/estimators/ad_estimators.py:# type: ignore[name-defined]and# noqa: F821forBoudingBox.doptools/optimizer/config.py:# noqa: F401on exported imports,# noqa: E501on long descriptor strings.doptools/__init__.py,doptools/chem/__init__.py,doptools/optimizer/__init__.py,doptools/cli/__init__.py:# noqa: F401,F403for star exports.tests/conftest.py,tests/data/chem/generate_expected.py:# type: ignore[import-untyped]foryaml.Non-Typing Behavior Changes
doptools/chem/chem_features.py:ChythonLinear.transformnow usesDataFrame.mapinstead ofapplymap(pandas 3 compatibility).doptools/chem/chem_features.py:calculate_scoresnow raisesValueErrorfor unknown task types (previously fell through).doptools/cli/rebuilder.py:rebuild_from_filenow explicitly raisesNotImplementedError.Tests & Lint
pre-commit run --all-filespython -m pytest -q -p no:cacheprovider(99 passed, 3 skipped)Files Changed
.isort.cfgdoptools/__init__.pydoptools/chem/__init__.pydoptools/chem/chem_features.pydoptools/chem/coloratom.pydoptools/chem/utils.pydoptools/cli/__init__.pydoptools/cli/ensemble_model_rebuilding.pydoptools/cli/launch_optimizer.pydoptools/cli/launch_preparer.pydoptools/cli/plotter.pydoptools/cli/rebuilder.pydoptools/estimators/ad_estimators.pydoptools/estimators/consensus.pydoptools/optimizer/__init__.pydoptools/optimizer/config.pydoptools/optimizer/optimizer.pydoptools/optimizer/preparer.pysetup.pytests/chem/test_chem_features.pytests/chem/test_coloratom.pytests/chem/test_solvents.pytests/chem/test_utils.pytests/cli/test_ensemble_model_rebuilding.pytests/cli/test_launch_optimizer.pytests/cli/test_launch_preparer.pytests/cli/test_plotter.pytests/cli/test_rebuilder.pytests/conftest.pytests/data/chem/generate_expected.pytests/estimators/test_ad_estimators.pytests/estimators/test_consensus.pytests/optimizer/test_config.pytests/optimizer/test_optimizer.pytests/optimizer/test_preparer.pytests/optimizer/test_utils.pyMR_NOTES.md