Skip to content

python-ldap: add package stubs - #16103

Open
marlon-costa-dc wants to merge 3 commits into
python:mainfrom
marlon-costa-dc:python-ldap-stubs
Open

python-ldap: add package stubs#16103
marlon-costa-dc wants to merge 3 commits into
python:mainfrom
marlon-costa-dc:python-ldap-stubs

Conversation

@marlon-costa-dc

Copy link
Copy Markdown

Resumo

Adiciona stubs parciais para o pacote python-ldap, incluindo módulos públicos, metadados e a dependência tipada de pyasn1.

Validação

  • PATH="$PWD/.venv/bin:$PATH" .venv/bin/python tests/runtests.py stubs/python-ldap
  • pre-commit, estrutura, Pyright, ty e mypy concluídos com sucesso
  • stubtest não foi executado porque instala e executa código arbitrário do PyPI

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

zulip (https://github.com/zulip/zulip)
- zproject/dev_settings.py:142: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zproject/dev_settings.py:149: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zproject/dev_settings.py:152: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zproject/dev_settings.py:157: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
- zproject/prod_settings_template.py:177: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zproject/prod_settings_template.py:228: error: Module has no attribute "SCOPE_SUBTREE"  [attr-defined]
- zproject/backends.py:25: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zproject/backends.py:1611: error: Module has no attribute "SCOPE_BASE"  [attr-defined]
+ zproject/backends.py:1616: error: Module has no attribute "NO_SUCH_OBJECT"  [attr-defined]
- zerver/lib/test_helpers.py:17: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zerver/lib/test_helpers.py:62: error: Name "ldap.LDAPError" is not defined  [name-defined]
+ zerver/lib/test_helpers.py:65: error: Name "ldap.INVALID_CREDENTIALS" is not defined  [name-defined]
+ zerver/lib/test_helpers.py:68: error: Name "ldap.NO_SUCH_OBJECT" is not defined  [name-defined]
+ zerver/lib/test_helpers.py:71: error: Name "ldap.ALREADY_EXISTS" is not defined  [name-defined]
- zproject/computed_settings.py:1102: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zproject/computed_settings.py:1104: error: Module has no attribute "OPT_REFERRALS"  [attr-defined]
+ zproject/computed_settings.py:1114: error: Module has no attribute "OPT_REFERRALS"  [attr-defined]
- zerver/tests/test_email_notifications.py:5: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zerver/tests/test_email_notifications.py:298: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
- zerver/tests/test_auth_backends.py:19: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zerver/tests/test_auth_backends.py:7781: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:7904: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:7907: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:8131: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:8515: error: Module has no attribute "LDAPError"  [attr-defined]
+ zerver/tests/test_auth_backends.py:9778: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:9845: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zerver/tests/test_auth_backends.py:9945: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
- zproject/test_extra_settings.py:3: error: Cannot find implementation or library stub for module named "ldap"  [import-not-found]
+ zproject/test_extra_settings.py:79: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]
+ zproject/test_extra_settings.py:83: error: Module has no attribute "SCOPE_ONELEVEL"  [attr-defined]

@donbarbos donbarbos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the contributing! Here are a few things I noticed during a quick review.

I noticed that Any is often used as a placeholder. In typeshed, it's generally preferred to either add a (brief) comment explaining why Any is being used or what types are expected, or use Incomplete instead.
In your case, Incomplete would be a better fit.

If you need a placeholder for "not fully typed yet", either leave out the annotation or use Incomplete (imported from _typeshed) when that's not syntactically impossible. For example, you could use Iterable[Incomplete] to mark that you know that it's an iterable, but the exact types in the iterable are to be determined.

Comment on lines +1 to +11
version = "3.4.*"
dependencies = ["types-pyasn1"]
upstream-repository = "https://github.com/python-ldap/python-ldap"
extra-description = """
Type stubs for python-ldap, covering the public API as documented at
https://www.python-ldap.org/doc/html/api.html.
"""
partial-stub = true

[tool.stubtest]
stubtest-dependencies = ["python-ldap"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for extra description and adding the package itself to stubtest dependencies (it is already there)

Suggested change
version = "3.4.*"
dependencies = ["types-pyasn1"]
upstream-repository = "https://github.com/python-ldap/python-ldap"
extra-description = """
Type stubs for python-ldap, covering the public API as documented at
https://www.python-ldap.org/doc/html/api.html.
"""
partial-stub = true
[tool.stubtest]
stubtest-dependencies = ["python-ldap"]
version = "3.4.*"
upstream-repository = "https://github.com/python-ldap/python-ldap"
dependencies = ["types-pyasn1"]
partial-stub = true
[tool.stubtest]
apt-dependencies = ["libsasl2-dev"]

Comment thread pyproject.toml
Comment on lines +44 to +45
".pytype",
"python-ldap",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove unrelated diffs

Suggested change
".pytype",
"python-ldap",

Comment thread pyrightconfig.json
"stubs/geopandas",
// test cases use a custom config file
"**/@tests/test_cases",
"python-ldap"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove unrelated diffs

Suggested change
"python-ldap"

Comment thread python-ldap

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also delete unused file?

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.

3 participants