Skip to content

include py.typed in package#101

Merged
Cube707 merged 7 commits intomasterfrom
py-typed
Mar 15, 2023
Merged

include py.typed in package#101
Cube707 merged 7 commits intomasterfrom
py-typed

Conversation

@Cube707
Copy link
Copy Markdown
Collaborator

@Cube707 Cube707 commented Mar 2, 2023

this should enable mypy to analyse the package and fix #100

@phoenixr-codes can you please confirm this fixes the issue? Use this to install the pre-release version:

pip install -U --pre readchar==4.0.4.dev0

Cube707 and others added 2 commits March 2, 2023 12:11
this should enable mypy to analyse the package
@phoenixr-codes
Copy link
Copy Markdown

This does not fix the issue for some reason - even after upgrading mypy and clearing the cache.

Following https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages, it might be neccessary to set zip_safe to False.

@Cube707
Copy link
Copy Markdown
Collaborator Author

Cube707 commented Mar 3, 2023

hm, thats anoying. I will look into this some more...

@Cube707 Cube707 marked this pull request as draft March 3, 2023 11:33
Cube707 added 2 commits March 6, 2023 19:24
This should finally allow mypy to find the stubs
@Cube707
Copy link
Copy Markdown
Collaborator Author

Cube707 commented Mar 6, 2023

@phoenixr-codes it should work now, could you please try again? Use:

pip install -U --pre readchar==4.0.4.dev1

@Cube707 Cube707 marked this pull request as ready for review March 6, 2023 18:32
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 6, 2023

Coverage Status

Coverage: 94.156%. Remained the same when pulling 6a6bda2 on py-typed into 4a69e22 on master.

@phoenixr-codes
Copy link
Copy Markdown

Still does not work. The py.typed seems to be excluded during the build.

Going to the site packages

python -c "print(__import__('site').getsitepackages()[0])"

and looking at some library's files, shows that some of them
contain a py.typed file - readchar does not.

I have managed to create a library which mypy recognizes as typed by using this pyproject.toml file:

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "typing_mypy_test"
version = "0.0.2"

[tool.setuptools.package-data]
typing_mypy_test = ["py.typed"]

[tool.setuptools]
zip-safe = false
# file: main.py
def add(a: float, b: float) -> float:
    return a + b

Directory Structure (after python -m build):

.
├── build
│   ├── bdist.linux-x86_64
│   └── lib
│       └── typing_mypy_test
│           ├── main.py
│           └── py.typed
├── dist
│   ├── typing_mypy_test-0.0.1-py3-none-any.whl
│   ├── typing_mypy_test-0.0.1.tar.gz
│   ├── typing_mypy_test-0.0.2-py3-none-any.whl
│   └── typing_mypy_test-0.0.2.tar.gz
├── pyproject.toml
├── typing_mypy_test
│   ├── main.py
│   └── py.typed
└── typing_mypy_test.egg-info
    ├── PKG-INFO
    ├── SOURCES.txt
    ├── dependency_links.txt
    ├── not-zip-safe
    └── top_level.txt

@Cube707
Copy link
Copy Markdown
Collaborator Author

Cube707 commented Mar 7, 2023

But I made sure that this time the file is included in both the .tar.gz and the wheel, wird.

But thanks for the hints from other packages, I will look how they handle it

@Cube707
Copy link
Copy Markdown
Collaborator Author

Cube707 commented Mar 8, 2023

Ok I found the problem. My release-pipeline is a bust and actually always releases master, so these changes are not in the pre-release versions... -_-

If you have the time you could try installing directly from the repo, like this:

pip install -U git+https://github.com/magmax/[email protected]

I will fix the pipeline...

@Cube707
Copy link
Copy Markdown
Collaborator Author

Cube707 commented Mar 9, 2023

@phoenixr-codes The pipeline is fixed and the newest pre-release version now actually containes the changes (also in the versions pushed to pypi). So installing this should work:

pip install -U --pre readchar==4.0.4.dev2

@Cube707 Cube707 merged commit b44a91c into master Mar 15, 2023
@Cube707 Cube707 deleted the py-typed branch March 15, 2023 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing py.typed marker

3 participants