Skip to content

Add stubs for django-import-export #11709

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

Merged
merged 19 commits into from
Dec 28, 2024
Merged

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Apr 3, 2024

Was discussed in django-import-export/django-import-export#1783

Checklist:

  • formats
  • templatetags
  • __init__.pyi
  • admin.pyi
  • exceptions.pyi
  • fields.pyi
  • forms.pyi
  • instance_loaders.pyi
  • mixins.pyi
  • resources.pyi
  • results.pyi
  • signals.pyi
  • tmp_storages.pyi
  • utils.pyi
  • widgets.pyi

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Viicos Viicos force-pushed the django-import-export branch from 882abe4 to 5b4791a Compare April 4, 2024 19:43

This comment has been minimized.

`render` and `clean` should be redefined on each subclass
as the return value can change. However, this is usually
not an API users will have to deal with, so not worth
the trouble

This comment has been minimized.

@Viicos Viicos force-pushed the django-import-export branch from 9e3c783 to 0248aa5 Compare April 14, 2024 09:07

This comment has been minimized.

@Viicos Viicos force-pushed the django-import-export branch from 60a0ee7 to affd870 Compare April 14, 2024 10:09

This comment has been minimized.

1 similar comment

This comment has been minimized.

@Viicos Viicos force-pushed the django-import-export branch from cb688bc to 81ff10c Compare April 14, 2024 10:47
@Viicos
Copy link
Contributor Author

Viicos commented Apr 14, 2024

I know there's a lot being added here, so I'd understand if this can't get merged.

I'm also wondering how to fix the issue when Django is being imported? 🤔

@Viicos Viicos marked this pull request as ready for review April 14, 2024 10:49
@Viicos Viicos changed the title Add base stubs for django-import-export Add stubs for django-import-export Apr 14, 2024

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Apr 14, 2024

The pyright tests are failing, since tablib has no stubs or type annotations yet. So instead of trying to import it, in typeshed we usually just type alias any imported items, like this:

from _typeshed import Incomplete

Dataset: TypeAlias = Incomplete  # tablib.Dataset

The easiest way to work around the stubtest problem for now is to set skip = true in the [tool.stubtest] table of METADATA.toml. Please add a comment why this is a necessary.

This comment has been minimized.

@Viicos Viicos force-pushed the django-import-export branch from fed5004 to d78b26f Compare April 15, 2024 07:07

This comment has been minimized.

This comment has been minimized.

@Viicos
Copy link
Contributor Author

Viicos commented Apr 15, 2024

Interesting pytype error..

@srittau
Copy link
Collaborator

srittau commented Apr 15, 2024

Interesting pytype error..

Considering that Library.simple_tag doesn't seem to change the signature, it's probably easiest to just leave it off.

We also need to add django-stubs to the stub uploader allowlist.

srittau added a commit to typeshed-internal/stub_uploader that referenced this pull request Apr 15, 2024

This comment has been minimized.

@batiste
Copy link

batiste commented Nov 25, 2024

Any news on this one? I suppose I will just suppress mypy for this package then.
Cheers for the good work already done for this!

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@JelleZijlstra
Copy link
Member

There's a few remaining CI issues:

  • pytype: stubs/django-import-export/import_export/templatetags/import_export_tags.pyi (3.12): pytype.load_pytd.BadDependencyError: Can't find pyi for 'register', referenced from 'import_export.templatetags.import_export_tags'. This file uses an attribute of a global as a decorator, which is a rare pattern that pytype may not support. Consider removing the decorator and typing the function to whatever type results from the decorator.
  • pyright: /home/runner/work/typeshed/typeshed/stubs/setuptools/setuptools/compat/py310.pyi:9:81 - error: Unnecessary "# pyright: ignore" rule: "reportMissingImports" (reportUnnecessaryTypeIgnoreComment). I understand this is because this PR introduces a dependency on django-stubs, which in turn pulls some other packages into the environment that make it so we don't need that ignore any more. Let's just remove the pyright ignore.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Viicos
Copy link
Contributor Author

Viicos commented Dec 28, 2024

Once merged, I can tackle the update in a separate PR

@JelleZijlstra JelleZijlstra merged commit eb8af63 into python:main Dec 28, 2024
49 checks passed
@Viicos Viicos deleted the django-import-export branch December 28, 2024 15:57
hoel-bagard pushed a commit to hoel-bagard/typeshed that referenced this pull request Jan 5, 2025
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.

4 participants