Skip to content

Allow inline type hints to be packaged and distributed (PEP561) #223

Description

@jamesdow21

Driver version

Redshift version

Client Operating System

Python version

Table schema

Problem description

It looks like this package has type annotations fully specified inline, but mypy doesn't recognize that the type hints can be used without a "py.typed" marker file (as described in PEP561).

  1. Expected behaviour: Mypy recognizes the inline annotations
  2. Actual behaviour: Mypy errors and skips analyzing anything from the package
  3. Error message/stack trace: error: Skipping analyzing "redshift_connector": module is installed, but missing library stubs or py.typed marker [import-untyped]
  4. Any other details that can be helpful: Very simple fix, just need to add a blank file named "py.typed" to the package root and make sure setuptools includes it in the sdist and wheel

Python Driver trace logs

Reproduction code

Activity

  1. Brooke-white commented on Jun 26, 2024

    @Brooke-white
    Contributor

    Hi @jamesdow21 , my apologies for the delay in response for this issue and your PR. Also, thank you for taking the time to open a PR for this issue.

  2. DavidGeorge528 commented on Aug 1, 2024

    @DavidGeorge528

    Not sure if this issue is fixed. I have the latest version of redshift-connector
    redshift-connector==2.1.3

    And inside my site-packages I don't see the py.typed file

    image

    And I also still get the error from mypy:

    redshift.py:1:1: error: Skipping analyzing "redshift_connector": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    redshift.py:1:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
  3. jamesdow21 commented on Oct 24, 2024

    @jamesdow21
    ContributorAuthor

    Can also confirm that the latest published version does not include the added py.typed file

    I can't replicate the behavior whenever I build locally though.

    Looking at the wheel published to PyPI, it shows that in the WHEEL metadata file Generator: bdist_wheel (0.33.6)

    I installed that same version of wheel and a version of setuptools that was published around the same time (setuptools==41.2.0) and tried building it locally again, but my local build still includes the py.typed file

  4. jamesdow21 commented on Nov 12, 2024

    @jamesdow21
    ContributorAuthor

    @Brooke-white Do you have any insight on what might be different between the local build script and the actual build and publish steps that upload the wheel to PyPI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions