Skip to content

Draft: add type annotations to (Base)Calculator

Tobias Pfeiffer requested to merge tgpfeiffer/ase:some-types into master

Not sure exactly what the policy of this project with respect to type annotations is, but as I personally find the code much easier to use with such annotations, I prepared a draft adding type annotations to the ase/calculators/calculator.py file. I also annotated some constant global lists/dicts as Sequence/Mapping, which should prevent them from being accidentally modified by some downstream code.

The code passes mypy 0.790 checks (see ase-dockers#4 (comment 925334743)) in my environment with latest version of all dependencies except numpy installed. (numpy needs a version < 1.22 to pass.)

There are a couple of places where I wasn't sure what the correct annotation is, or whether an Optional should be added or not. I have marked these places with TODO comments and would appreciate any input on them.

Merge request reports