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

Support for cython pure python syntax: cython.declare #8024

Open
jtoledo1974 opened this issue Jan 5, 2023 · 3 comments
Open

Support for cython pure python syntax: cython.declare #8024

jtoledo1974 opened this issue Jan 5, 2023 · 3 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@jtoledo1974
Copy link

Bug description

"""Test for cython pure python cython.declare"""
import cython

MY_VAR = cython.declare(cython.int, 0)

Configuration

[testoptions]
requires: cython

Command used

pylint regression_cython_declare.py

Pylint output

************* Module regression_cython_declare
tests/functional/r/regression_02/regression_cython_declare.py:4:24: E1101: Module 'cython' has no 'int' member; maybe 'bint'? (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior


Your code has been rated at 10.00/10

Pylint version

pylint 2.16.0-dev
astroid 2.12.13
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

OS / Environment

Needs cython. The default cython package as of today is
Cython==0.29.32

Additional dependencies

No response

@jtoledo1974 jtoledo1974 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 5, 2023
@jtoledo1974
Copy link
Author

Cython has a "pure python" mode with which you can write your python code using valid python syntax.

I believe pylint should be able to recognize it and avoid reporting correct syntax when using cython. In this case, it is expected that the cython module doesn't provide the members.

I'll do a pull request with the test case, and will try to produce a patch.

@jtoledo1974
Copy link
Author

jtoledo1974 commented Jan 5, 2023

For reference, and if I fail to produce a patch, a workaround is to add this to the pyproject.toml file:

[tool.pylint.BASIC]
ignored-modules = ["cython"]

Using ignored-modules is even better than setting generated-members = "cython.*", as it also deals with cimports nicely.

@clavedeluna
Copy link
Collaborator

I expect the patch would need to be in astroid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

2 participants