Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types-protobuf fails pre-commit cache #11254

Closed
Itay4 opened this issue Jan 7, 2024 · 17 comments
Closed

types-protobuf fails pre-commit cache #11254

Itay4 opened this issue Jan 7, 2024 · 17 comments
Assignees

Comments

@Itay4
Copy link

Itay4 commented Jan 7, 2024

when configuring pre-commit mypy to run with types-protobuf, for example:

  -   repo: https://github.com/pre-commit/mirrors-mypy
      rev: v1.8.0
      hooks:
        -   id: mypy
            additional_dependencies:
              - types-protobuf

it fails with the following:

mypy.....................................................................Failed
- hook id: mypy
- exit code: 2

mypy: can't read file '/home/runner/.cache/pre-commit/repoem44ysms/py_env-python3.10/lib/python3.10/site-packages//google': No such file or directory

i suspect its related to #11249, but not sure - @AlexWaygood @hauntsaninja i would appreciate your insights here

@andylamp
Copy link

andylamp commented Jan 7, 2024

Encountering the same issue as well, this was previously working....

edit: happy to provide logs etc if that helps, but the resulting message I get when I run the pre-commits is the same as @Itay4 's output shown above.

edit2: if it helps, I tried using both Python 3.10 and Python 3.11 virtual envs for running the pre-commit hooks but the same error occurs.

edit3: I cannot find a way to use a "downgraded" of an additional_dependencies entry in mypy as a pre-commit hook so cannot check that previous versions worked, but we certainly did not have this problem previously...

@srittau
Copy link
Collaborator

srittau commented Jan 8, 2024

Neither #11249, not #11245, the two PRs included in the latest release, should have an influence here. I'm not sure what exactly is going on here, but types-protobuf doesn't add a google directory, but a google-stubs directory, so it's no wonder that mypy can't find it. Does downgrading to types-protobuf 4.24.0.4 help?

@andylamp
Copy link

andylamp commented Jan 8, 2024

Hi @srittau, as I mentioned previously I do know a way to specific specific version within mypy in a pre-commit environment.

Using the default though, exhibits the behavior mentioned by the original author.

If you know a way to "pin" an additional depency version, let me know and I can test it.

@srittau
Copy link
Collaborator

srittau commented Jan 8, 2024

This problem was introduced by typeshed-internal/stub_uploader#109. Previously, the google-stubs directory was missing the py.typed file that marked the stubs as partial. I think this was an error according to the typing spec:

For namespace packages (see PEP 420), stub-only packages should use the -stubs suffix on only the root namespace package. All stub-only namespace packages should omit __init__.pyi files. py.typed marker files are not necessary for stub-only packages, but similarly to packages with inline types, if used, they should be in submodules of the namespace to avoid conflicts and for clarity.

Cc @Avasam

@Avasam
Copy link
Collaborator

Avasam commented Jan 8, 2024

If I understand correctly, "google" is a namespace package and the py.typed marker should be found in google-stubs/protobuf/ rather than google-stubs/ ? (that's what I'm getting from the part of the spec srittau is quotig)

In the short term, simply setting partial_stub to false in https://github.com/python/typeshed/blob/main/stubs/protobuf/METADATA.toml (and namespace packages in general) with an appropriate comment should be enough to fix the current issue (no py.typed file should be generated for non-partial stubs, as it is optional and redundant as per the spec).

In the longer term, we may want a way to identify those so stub_uploader adds the py.typed file to the submodules. Like the lack of any file at the top-level.

@andylamp
Copy link

andylamp commented Jan 8, 2024

@Avasam thanks for the explanation, any workarounds for this issue for the interim :-)?

@srittau
Copy link
Collaborator

srittau commented Jan 8, 2024

If I understand correctly, "google" is a namespace package and the py.typed marker should be found in google-stubs/protobuf/ rather than google-stubs/ ? (that's what I'm getting from the part of the spec srittau is quotig)

That's my understanding as well. I think making the necessary changes to the stub_uploader should be fairly simple, although I haven't investigated deeply.

@Avasam
Copy link
Collaborator

Avasam commented Jan 8, 2024

@Avasam thanks for the explanation, any workarounds for this issue for the interim :-)?

@andylamp Check the very bottom of https://github.com/pre-commit/mirrors-mypy 's readme. I'm pretty sure it's just using pip, so the same markers should work to pin to an older version: types-protobuf==X.X.X

@srittau srittau self-assigned this Jan 8, 2024
srittau added a commit to typeshed-internal/stub_uploader that referenced this issue Jan 8, 2024
This is a preliminary refactoring for fixing python/typeshed#11254. The idea is that the new class `PackageData` encapsulates all data concerning packages and their contents. This allows us later to find the top-level non-namespace packages, instead of just the top-level packages as we are doing now.
@tonkolviktor
Copy link

Hi, would it be possible to delete this version from pypi?

@srittau
Copy link
Collaborator

srittau commented Jan 8, 2024

I'm not sure who has access to the packages on PyPI. I think @ilevkivskyi could do it.

@alanbchristie
Copy link

alanbchristie commented Jan 9, 2024

Also finding all my CI pipelines have broken. In my GitLab CI script I have had to pin it to 4.24.0.4 with the following: -

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v1.8.0
  hooks:
  - id: mypy
    files: ^app
    args:
    - --ignore-missing-imports
    additional_dependencies:
    - types-protobuf==4.24.0.4
    - types-PyYAML
    - types-python-dateutil
    - types-pytz
    - types-requests

Any chance this release can be pulled very soon?

I would suggest that publishing what looks like a nightly build to PyPI (4.24.0.20240106) is probably not recommended in the future?

@Avasam
Copy link
Collaborator

Avasam commented Jan 9, 2024

I would suggest that publishing what looks like a nightly build to PyPI (4.24.0.20240106) is probably not recommended in the future?

Stubs are now calendar-versionned, (hence the bump from 4, an index, to 20240106, a date) with the express purpose to communicate that the version number is not semantic (and has never been). There's no such thing as a major/minor/patch/nightly update in typeshed's stubs.
See #10837, #6843 and typeshed-internal/stub_uploader#105 for more details.

I have had to pin it to 4.24.0.4 with the following: -
Any chance this release can be pulled very soon?

Hopefully? But I'd recommend pinning your libraries versions either way if you want to avoid unexpected CI breakage. Even an update that fixes or improves existing stubs, or an update to type-checkers, could cause your CI to fail all of a sudden (like new false-positives, using new features your type-checker version doesn't support, fixing a false-positive you had suppressed, etc.)

JelleZijlstra pushed a commit to typeshed-internal/stub_uploader that referenced this issue Jan 11, 2024
This is a preliminary refactoring for fixing python/typeshed#11254. The idea is that the new class `PackageData` encapsulates all data concerning packages and their contents. This allows us later to find the top-level non-namespace packages, instead of just the top-level packages as we are doing now.
@ilevkivskyi
Copy link
Member

Do you still need me to delete some package from PyPI? If yes, could you please post exactly what is needed (i.e. library and version)?

@alanbchristie
Copy link

Hi @ilevkivskyi - For me? I fix the problems with types-protobuf==4.24.0.4 as 4.24.0.20240106 breaks mypy (see #11263).

That's (obviously) not a solution to the problem.

I have a work-around and I don't have a strong feeling on the topic (it's not my repo) so I'm fine - but it means the latest release can't be used by me (and, I suspect, others) because of the problems it seems to cause with mypy.

If someone thinks the problem with types-protobuf is caused by types-protobuf then I guess, yes, pull it. Does someone know what the problem is?

@tonkolviktor
Copy link

Hi @ilevkivskyi , the removal idea come from me, IMHO if we know that the release is broken and the fix is not coming in hours, then it should be removed: types-protobuf 4.24.0.20240106
buuut I'm just a guy from the internet :)

parthea added a commit to googleapis/python-cloud-core that referenced this issue Jan 22, 2024
parthea added a commit to googleapis/python-cloud-core that referenced this issue Jan 24, 2024
* build(python): fix `docs` and `docfx` builds

Source-Link: googleapis/synthtool@fac8444
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5ea6d0ab82c956b50962f91d94e206d3921537ae5fe1549ec5326381d8905cfa

* See googleapis/synthtool#1916

* See python/typeshed#11254

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea added a commit to googleapis/python-api-core that referenced this issue Jan 25, 2024
parthea added a commit to googleapis/python-api-core that referenced this issue Jan 25, 2024
* build(python): fix `docs` and `docfx` builds

Source-Link: googleapis/synthtool@fac8444
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5ea6d0ab82c956b50962f91d94e206d3921537ae5fe1549ec5326381d8905cfa

* See python/typeshed#11254

* See googleapis/synthtool#1916

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
srittau added a commit to typeshed-internal/stub_uploader that referenced this issue Jan 29, 2024
This is a preliminary refactoring for fixing python/typeshed#11254. The idea is that the new class `PackageData` encapsulates all data concerning packages and their contents. This allows us later to find the top-level non-namespace packages, instead of just the top-level packages as we are doing now.
@Avasam
Copy link
Collaborator

Avasam commented Jan 31, 2024

Update to those following this issue: with typeshed-internal/stub_uploader#122, the latest version of types-protobuff (4.24.0.20240129) shouldn't have this issue as it doesn't have any py.typed marker.

The marker file should properly be re-introduced in the subpackages (rather than the root of the namespace package), in a future update to stub_uploader.

@Avasam
Copy link
Collaborator

Avasam commented Mar 14, 2024

This issue should be resolved and we haven't had any new complaints since then.
For the missing py.typed marker in namespace packages, please refer to typeshed-internal/stub_uploader#121 (comment) for tracking.

@Avasam Avasam closed this as completed Mar 14, 2024
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

No branches or pull requests

7 participants