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

build: log build sources with -v #9672

Merged
merged 1 commit into from
Oct 31, 2020
Merged

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Oct 31, 2020

With the changes I've been making to mypy's import handling, I think
this would be a useful thing to add preemptively.

Note that I would have found this very useful at points, and I think
others would too, eg #7672 and #8584

The existing logging ignores source_modules and source_text and doesn't
help with determining what mypy things the module name for a given file
is. This is useful for namespace package issues as in the complaint in #8584.

With the changes I've been making to mypy's import handling, I think
this would be a useful thing to add preemptively.

Note that I would have found this very useful at points, and I think
others would too, eg python#7672 and python#8584

The existing logging ignores source_modules and source_text and won't
help with determining what mypy things the module name for a given file
is, which is useful for namespace package issues as in the complaint in python#8584.
@gvanrossum
Copy link
Member

Hmm, I see that when I turn this on to mypy itself, it claims that some sources from typeshed/stdlib/2 and typeshed/thir_party/2 are found, e.g.

LOG:  Found source:           BuildSource(path='mypy/typeshed/stdlib/2/distutils/__init__.pyi', module='distutils', has_text=False, base_dir='mypy/typeshed/stdlib/2')
LOG:  Found source:           BuildSource(path='mypy/typeshed/stdlib/2/distutils/command/__init__.pyi', module='distutils.command', has_text=False, base_dir='mypy/typeshed/stdlib/2')
LOG:  Found source:           BuildSource(path='mypy/typeshed/stdlib/2/distutils/command/bdist.pyi', module='distutils.command.bdist', has_text=False, base_dir='mypy/typeshed/stdlib/2')
.
.
.
LOG:  Found source:           BuildSource(path='mypy/typeshed/third_party/2/ipaddress.pyi', module='ipaddress', has_text=False, base_dir='mypy/typeshed/third_party/2')
LOG:  Found source:           BuildSource(path='mypy/typeshed/third_party/2/pathlib2.pyi', module='pathlib2', has_text=False, base_dir='mypy/typeshed/third_party/2')
LOG:  Found source:           BuildSource(path='mypy/typeshed/third_party/2/pymssql.pyi', module='pymssql', has_text=False, base_dir='mypy/typeshed/third_party/2')

(A total of 265 files, out of 1436 reported.)

Any idea what's up with that?

@gvanrossum
Copy link
Member

Hm, I'm guessing this is the new, improved file search? This was from

python -m mypy -v mypy

It does the right thing when I run

python -m mypy -v -p mypy

IIRC the former used to work. Well, I guess I never liked typeshed being embedded inside mypy (nor the test subdir for that matter), but here we are.

@gvanrossum
Copy link
Member

IOW I realize I have to declare in favor of this PR, since this actually showed the error of my ways... :-)

@hauntsaninja
Copy link
Collaborator Author

:-)
I also noticed the error message isn't accurate, for which I made #9674!

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

But I still want a -v flag that just prints the list of sources, and not all the other stuff that’s logged by -v. That could become -vv.

Also, wouldn’t it be nice if each source file was logged just before it got checked, instead of all ahead of the checking? Then it would intersperse this activity log with the errors, as found.

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Oct 31, 2020

Yeah that would be nice, and there's still the "show all files reached by following imports" part of your original request.

It also occurred to me that python -m mypy --config-file mypy_self_check.ini -p mypy --namespace-packages -v should also end up checking all of typeshed, but it doesn't. So #9616 isn't quite the fix I thought it was...

@hauntsaninja hauntsaninja merged commit fd16f84 into python:master Oct 31, 2020
@hauntsaninja hauntsaninja deleted the builds branch October 31, 2020 19:42
@gvanrossum
Copy link
Member

Presuming you meant ‘-p mypy’, maybe it just stops descending when it finds a package named ‘mypy’?

@hauntsaninja
Copy link
Collaborator Author

Yeah, I meant -p mypy (edited above). The issue is that modulefinder recurses differently in the presence of __init__.py; we hit this check even if we allow namespace packages, which is not what we want

@samskiter
Copy link

Also, wouldn’t it be nice if each source file was logged just before it got checked, instead of all ahead of the checking? Then it would intersperse this activity log with the errors, as found.

I know you posted this a while ago but definitely a big YES to this. - Currently trying to help fix this VSCode mypy extension and that feature would come in might handy for this bug microsoft/vscode-mypy#123

Any suggestions for a quick fix? If the output can include files checked, even if they have no error, it makes clearing errors on files a lot easier...

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