Could Ansys include a `py.typed` file in the Granta STK for mypy compatibility?

Options
noahMDMi
noahMDMi Member Posts: 8
Photogenic First Comment
edited June 2023 in Materials

We use the Granta STK regularly, but also use mypy, a static type-checker for Python. Taking a look at the actual STK files when installed, they all have type hints, but without the py.typed file, mypy cannot infer any of the type hints when linting code.

While we can include this file manually by editing our site-packages, it is tedious to do that for every single virtual environment.

Would it be possible for Ansys to include this file in future releases of the STK?

Note: The py.typed file is literally an empty file named py.typed which is included in the root directory of the library. See PEP 561 for more information.

Tagged:

Best Answer

  • Andy_Grigg
    Andy_Grigg Member, Employee Posts: 23
    First Answer First Comment First Anniversary 5 Likes
    edited June 2023 Answer ✓
    Options

    Thanks for the recommendation! I'm glad you are finding the type hints we have on the interface useful.

    The reason we haven't included the py.typed file in our release so far is that I think to do so would be to make a commitment that the type hints are 100% correct and are validated with mypy during our release process. We currently haven't done this, and the type hints we have included are generally to help us when developing the software.

    However, given though that you are actively using the scripting toolkit and wanting to use a type hinted version, I will add this to our development backlog and we'll look to incorporate it into the release.

    Also, thank you both for your first posts in the Ansys developer forum!

Answers