Skip to content

refactor: Completed type hints and attribute annotations#18

Open
ICasciuc wants to merge 2 commits intoPOSidorov:devfrom
ICasciuc:dev
Open

refactor: Completed type hints and attribute annotations#18
ICasciuc wants to merge 2 commits intoPOSidorov:devfrom
ICasciuc:dev

Conversation

@ICasciuc
Copy link
Copy Markdown
Contributor

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. Fixed a bug for 'csv' in optimizer.py collect_data. (No args passed to index())
  • 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

Apl0x and others added 2 commits March 3, 2026 15:02
… 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,…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants