Skip to content

Conversation

berquist
Copy link
Member

@berquist berquist commented Mar 4, 2023

Not code style exactly, but I see it as part of #1122.

@berquist berquist added this to the v1.8 milestone Mar 4, 2023
from cclib.parser.utils import find_package

_found_psi4 = find_package("psi4")
if _found_psi4:
from psi4.core import Molecule


def _check_psi4(found_psi4):
def _check_psi4(found_psi4: bool) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's prudent to annotate internal functions? Something I normally don't do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should have been a response here: #1179 (comment):

I always do, since they may be reused many times, the body won’t get
checked if the signature isn’t annotated, and I’ve been bitten by this
before.

@berquist
Copy link
Member Author

berquist commented Mar 4, 2023 via email

additional_dependencies:
- numpy
- packaging
- pandas-stubs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not obvious to me why pandas is a dep.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def ccframe(ccobjs, *args, **kwargs):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should say exactly what this file is. It's technically not necessary for mypy to run.1 .pre-commit-config.yaml is a configuration file for https://pre-commit.com/, which is two things:

  1. A tool that runs linters and fixers from the command line. You do not need to have it as a pre-commit hook. Just doing https://pre-commit.com/#4-optional-run-against-all-the-files is enough.
  2. A free CI service that runs alongside GH workflows, ReadTheDocs, etc.

The benefit to having 1 is that everyone has a unified way of running all these tools that's independent from CI, specifically opaque GitHub Actions. You can have 1 without 2. 2 would mean that you get the benefits of the hook (clean repository) without forcing contributors to install the hook.

The reason pandas-stubs appears in additional_dependencies is because of how the tool works. For Python-based tools, it creates a fresh venv to run that tool in, and by default it only installs that tool. This means that mypy will not have access to any 3rd-party type information unless the dependencies or packages with only type stubs (for dependencies that don't ship them together) are also installed.

Footnotes

  1. For mypy configuration, you only need pyproject.toml or mypy.ini. I chose the former since everything is moving toward it anyway.

@berquist
Copy link
Member Author

berquist commented Mar 8, 2023

I think what I'll do is convert this from draft to PR once CI is fixed and leave everything as-is, so at least once more round of adding annotations, fixing annotations (wrong ones, fixing np.ndarray, ...), and cleaning up mypy settings is required before adding this to CI. I'll also check pyright without mypy. Pyre probably isn't important...

@berquist berquist marked this pull request as ready for review March 8, 2023 14:40
@berquist berquist requested review from shivupa and amandadumi March 8, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants