Commit 2438aa80 authored by Lars van den Haak's avatar Lars van den Haak
Browse files

Updated how to update version and fixes in readme

parent 33f04816
Pipeline #24364 canceled with stages
......@@ -6,4 +6,5 @@ __pycache__/
.ipynb_checkpoints/
build/
env/
nb_mypy.egg-info/
\ No newline at end of file
nb_mypy.egg-info/
dist/
......@@ -320,25 +320,16 @@
```
%% Cell type:code id: tags:
``` python
# reveal_type is not defined, but interpreted by mypy
# reveal_type is not defined, but interpreted by mypy.
# This extension also removes reveal_type calls, so we don't get errors.
reveal_type(mid([1, 2]))
reveal_type(mid(['a', 'b']))
```
%%%% Output: error
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-19-2c235a16a669> in <module>
1 # reveal_type is not defined, but interpreted by mypy
----> 2 reveal_type(mid([1, 2]))
3 reveal_type(mid(['a', 'b']))
NameError: name 'reveal_type' is not defined
%% Cell type:markdown id: tags:
### Advanced type hints
* `Optional`: if value can also be `None`
......
# Nb Mypy
_Nb Mypy_ is a facility to automatically run `mypy`[http://mypy-lang.org/] on Jupyter notebook cells as they are executed, whilst retaining information about the execution history.
_Nb Mypy_ is a facility to automatically run [`mypy`](http://mypy-lang.org/) on Jupyter notebook cells as they are executed, whilst retaining information about the execution history.
## Installation
......@@ -22,7 +22,6 @@ The package is build via PyPA's `build`, make sure you have the latest available
python3 -m pip install --upgrade build
```
You can then build the package from the current directory where `pyproject.toml` is located:
```bash
python3 -m build
......@@ -53,4 +52,4 @@ Here are the ways to use the line magic `%nb_mypy`
## Examples
For examples, see the Jupyter notebook [`Nb_Mypy.ipynb`](Nb_Mypy.ipynb).
For examples, see the Jupyter notebook [`Nb_Mypy.ipynb`](https://gitlab.tue.nl/jupyter-projects/nb_mypy/-/blob/master/Nb_Mypy.ipynb).
......@@ -13,7 +13,6 @@ Current version was inspired by github user BradyHu
https://gist.github.com/BradyHu/f4dc997d4b53f9b23e1120940fb8f0d1
"""
__version__ = '1.0.0'
import ast
import functools
......@@ -26,8 +25,17 @@ from mypy import api
import IPython # type: ignore
from IPython.core.magic import register_line_magic # type: ignore
# List names in names objects, or tuples.
#
from nb_mypy.version import __version__
class RevealRemover(ast.NodeTransformer):
"""Removes function calls to 'reveal_type'."""
def visit_Call(self, node):
if isinstance(node.func, ast.Name):
if node.func.id == 'reveal_type':
return ast.Constant(None)
return node
class Names(ast.NodeVisitor):
......@@ -386,6 +394,9 @@ def load_ipython_extension(ipython_shell: IPython.core.interactiveshell.Interact
ipython_shell.events.register(
'pre_run_cell', __NB_TYPECHECKER.type_check)
reveal_remover = RevealRemover()
ipython_shell.ast_transformers.append(reveal_remover)
@register_line_magic
def nb_mypy(line):
"""Inspect or modify mypy autochecking state.
......
__version__ = '1.0.2'
[build-system]
requires = [
"setuptools>=42",
"wheel",
"astor",
"mypy"
"wheel"
]
build-backend = "setuptools.build_meta"
\ No newline at end of file
[metadata]
name = nb_mypy
version = 1.0.0
author = Lars van den Haak, Tom Verhoeff
author_email = l.b.vandenhaak@gmail.com
license = MIT
description = Nb Mypy is a facility to automatically run mypy on Jupyter notebook cells as they are executed, whilst retaining information about the execution history.
long_description = file: README.md
long_description_content_type = text/markdown
......@@ -16,4 +16,8 @@ classifiers =
Framework :: IPython
[options]
packages = find:
python_requires = >=3.6
\ No newline at end of file
python_requires = >=3.6
install_requires =
astor >= 0.8, <1
mypy >= 0.7, <1
ipython >= 7.0, <8
\ No newline at end of file
from setuptools import setup
import re
def get_property(prop, file):
result = re.search(
r'{}\s*=\s*[\'"]([^\'"]*)[\'"]'.format(prop), open(file).read())
return result.group(1)
setup(
version=get_property('__version__', 'nb_mypy/version.py')
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment