Update deprecated typing imports to collections.abc#216
Conversation
Signed-off-by: brockdyer03 <brockdyer03@gmail.com>
|
Thank you for making a contribution. Please also run the other nox sessions simply with calling |
|
@brockdyer03 There is still a @haneug |
…n` with `types.UnionType` for type check Signed-off-by: brockdyer03 <brockdyer03@gmail.com>
|
I've run One other thing I changed is the use of |
While this isn't my project, I would caution against this as it means that when a user looks at the API documentation they will have to look at the function signature in addition to the docstring, which could become quite laborious for functions with many arguments (scrolling up and down constantly). Additionally, it should probably be discouraged to write docstrings in that manner in general in my opnion (e.g. writing """
Attributes
----------
dipole : tuple[float, float, float]
Dipole derivatives TX TY TZ in atomic units
"""one would write """
Attributes
----------
dipole : tuple of float
Dipole derivatives TX TY TZ in atomic units
"""or perhaps even """
Attributes
----------
dipole : tuple of float with length 3
Dipole derivatives TX TY TZ in atomic units
"""This would result in API documentation that is generally more human-readable, whereas the explicit type syntax is generally considered more machine-readable. In the end it's a matter of personal preference, but I think that making documentation that is generally in line with Numpy is a good idea since there are a considerable number of Python users that use Numpy and read their documentation, and thus are familiar with their format. |
@brockdyer03 |
|
Thank you for contributing to OPI! |
Description
A number of imports from the
typingmodule have been deprecated since Python 3.9 or 3.10, and were removed/updated in this PR.Some examples include:
typing.Callable->collections.abc.Callabletyping.Sequence->collections.abc.Sequencetyping.Tuple->tupletyping.Set->settyping.Union[Any, Any]->Any | Anytyping.Optional[Any]->Any | NoneTests
I ran
nox -s type_checkto test the changes.OS: Fedora 43 KDE Plasma
Python: 3.14.3
ORCA: 6.1.1
OpenMPI: 4.1.8
Release Notes
Fixed
typingtypes to be compliant with Python >=3.11 guidelines (Update deprecatedtypingimports tocollections.abc#216)