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

Add NoReturn to mypy_extensions #2637

Merged
merged 2 commits into from
Jan 9, 2017
Merged

Add NoReturn to mypy_extensions #2637

merged 2 commits into from
Jan 9, 2017

Conversation

ddfisher
Copy link
Collaborator

@ddfisher ddfisher commented Jan 4, 2017

Allow specifying that functions doesn't return in non-stub files.

@ambv
Copy link
Contributor

ambv commented Jan 4, 2017

mypy_extensions.py is not being checked by flake8 at this point, I think it's a simple omission because we need to whitelist things outside of mypy/. I'm about to change that but in the mean time, could you run flake8 extensions/mypy_extensions.py by hand and fix the whitespace so that I can enable the linter later without having to reformat your code?

BTW, #2635 waits for merging which speeds up tests significantly, that will help you get the green tick faster on pull requests like this one.

@ddfisher
Copy link
Collaborator Author

ddfisher commented Jan 4, 2017

Thanks for catching that! I went ahead and fixed all the whitespace errors in the file.

@ambv
Copy link
Contributor

ambv commented Jan 4, 2017

Nice! How do you expect NoReturn be used? I can't find any reference to it anywhere.

@ddfisher
Copy link
Collaborator Author

ddfisher commented Jan 4, 2017

See: python/typeshed#811

Basically, it will be valid only in the return type position and will indicate that a function never returns. IIRC this is the last feature preventing --warn-no-return from being on by default.

@ambv
Copy link
Contributor

ambv commented Jan 4, 2017

You need to land this for https://travis-ci.org/python/typeshed/jobs/188986766 to pass.

@ambv ambv mentioned this pull request Jan 4, 2017
@ddfisher
Copy link
Collaborator Author

ddfisher commented Jan 4, 2017

(Not quite -- the error was something else.)

@ilevkivskyi
Copy link
Member

A relevant issue on typing tracker python/typing#165
If this PR is merged, then probably the issue could be closed.

By the way, if you are writing a runtime implementation, maybe it is worth adding a docstring, a nice typing-style __repr__, prohibit subclassing, instantiation, and things like List[NoReturn], etc. (again following runtime implementation of typing types), and tests for these?

gvanrossum pushed a commit that referenced this pull request Jan 6, 2017
This change is a step towards removing `runtests.py` (see #1673).

The exclusion list in the flake8 configuration in `setup.cfg` has been updated
to enable running the linter from the root of the project by simply invoking
`flake8`.  This enables it to leverage its own file discovery and its own
multiprocessing queue without excessive subprocessing for linting every file.
This gives a minor speed up in local test runs. Before:

  total time in lint: 130.914682

After:

  total time in lint: 20.379915

There's an additional speedup on Travis because linting is now only performed
on Python 3.6.

More importantly, this means flake8 is now running over all files unless
explicitly excluded in `setup.cfg`. This will help avoiding unintentional
omissions in the future (see comments on #2637).

Note: running `flake8` as a single lazy subprocess in `runtests.py` doesn't
sacrifice any parallelism because the linter has its own process pool.

Minimal whitespace changes were required to `mypy_extensions.py` but in return
flake8 will check it now exactly like it checks the rest of the `mypy/*`
codebase.  Those are also done on #2637 but that hasn't landed yet.

Finally, flake8-bugbear and flake8-pyi were added to test requirements to make
the linter configuration consistent with typeshed.  I hope the additional
checks will speed up future pull requests by automating bigger parts of the
code review.  The pyi plugin enables forward reference support when linting
.pyi files.  That means it's now possible to run `flake8` inside the typeshed
submodule or on arbitrary .pyi files during development (which your editor
could do for you), for example on fixtures.  See discussion on #2629 on checks
that are disabled and why.
@elazarg
Copy link
Contributor

elazarg commented Jan 7, 2017

So no Union[()]?

@gvanrossum
Copy link
Member

gvanrossum commented Jan 7, 2017 via email

@gvanrossum gvanrossum merged commit 083a1a8 into master Jan 9, 2017
@gvanrossum gvanrossum deleted the noreturn-extension branch January 9, 2017 17:10
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.

5 participants