Skip to content

Update stubutil.py is_c_module with .pyd check #5284

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 2 commits into from
Jun 27, 2018

Conversation

AlexArcPy
Copy link
Contributor

Added check for .pyd file extension used on Windows

Added check for .pyd file extension used on Windows
mypy/stubutil.py Outdated
@@ -87,7 +87,8 @@ def find_unique_signatures(sigs: Sequence[Sig]) -> List[Sig]:


def is_c_module(module: ModuleType) -> bool:
return '__file__' not in module.__dict__ or module.__dict__['__file__'].endswith('.so')
return '__file__' not in module.__dict__ or any(module.__dict__['__file__'].endswith(
ext) for ext in ['.so', '.pyd'])
Copy link
Member

Choose a reason for hiding this comment

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

This is causing the linter to fail:

./mypy/stubutil.py:91:7: E121 continuation line under-indented for hanging indent

You can run the linter locally: flake8 mypy/stubutil.py

Though honestly I would refactor the code a little more -- the any() feels like it makes the code more complex than it needs to be. Maybe use os.path.splitext()?

Use os.path.splitext instead of str.endswith and breaking long line properly
@AlexArcPy
Copy link
Contributor Author

Thanks, Guido! I did not dare to refactor, but thanks for the hint, it is done, the linter should be happy now. Please review the latest changes and let me know if there is anything more that should be fixed.

@gvanrossum gvanrossum merged commit f7f3887 into python:master Jun 27, 2018
@gvanrossum
Copy link
Member

Thanks Alex! That was actually exactly the refactoring I was thinking of. :-)

@mikiboii
Copy link

i dont understand how didi u generate pyi file for pyd python 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