Start working with mypy

This commit is contained in:
Dave Halter
2020-07-25 15:05:42 +02:00
parent 34152d29b2
commit a474895764
5 changed files with 61 additions and 48 deletions

View File

@@ -7,11 +7,7 @@ import shutil
import platform import platform
import logging import logging
import warnings import warnings
import pickle
try:
import cPickle as pickle
except:
import pickle
from parso.file_io import FileIO from parso.file_io import FileIO

View File

@@ -149,8 +149,8 @@ class Issue(object):
class Rule(object): class Rule(object):
code = None code: int
message = None message: str
def __init__(self, normalizer): def __init__(self, normalizer):
self._normalizer = normalizer self._normalizer = normalizer

View File

@@ -23,7 +23,7 @@ class NodeOrLeaf(object):
The base class for nodes and leaves. The base class for nodes and leaves.
""" """
__slots__ = () __slots__ = ()
type = None type: str
''' '''
The type is a string that typically matches the types of the grammar file. The type is a string that typically matches the types of the grammar file.
''' '''
@@ -257,7 +257,6 @@ class BaseNode(NodeOrLeaf):
A node has children, a type and possibly a parent node. A node has children, a type and possibly a parent node.
""" """
__slots__ = ('children', 'parent') __slots__ = ('children', 'parent')
type = None
def __init__(self, children): def __init__(self, children):
self.children = children self.children = children

View File

@@ -10,3 +10,16 @@ ignore =
E226, E226,
# line break before binary operator # line break before binary operator
W503, W503,
[mypy]
disallow_subclassing_any = True
# Avoid creating future gotchas emerging from bad typing
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
warn_unused_configs = True
warn_unreachable = True
strict_equality = True

View File

@@ -12,42 +12,47 @@ __AUTHOR_EMAIL__ = 'davidhalter88@gmail.com'
readme = open('README.rst').read() + '\n\n' + open('CHANGELOG.rst').read() readme = open('README.rst').read() + '\n\n' + open('CHANGELOG.rst').read()
setup(name='parso', setup(
version=parso.__version__, name='parso',
description='A Python Parser', version=parso.__version__,
author=__AUTHOR__, description='A Python Parser',
author_email=__AUTHOR_EMAIL__, author=__AUTHOR__,
include_package_data=True, author_email=__AUTHOR_EMAIL__,
maintainer=__AUTHOR__, include_package_data=True,
maintainer_email=__AUTHOR_EMAIL__, maintainer=__AUTHOR__,
url='https://github.com/davidhalter/parso', maintainer_email=__AUTHOR_EMAIL__,
license='MIT', url='https://github.com/davidhalter/parso',
keywords='python parser parsing', license='MIT',
long_description=readme, keywords='python parser parsing',
packages=find_packages(exclude=['test']), long_description=readme,
package_data={'parso': ['python/grammar*.txt', 'py.typed', '*.pyi', '**/*.pyi']}, packages=find_packages(exclude=['test']),
platforms=['any'], package_data={'parso': ['python/grammar*.txt', 'py.typed', '*.pyi', '**/*.pyi']},
python_requires='>=3.6', platforms=['any'],
classifiers=[ python_requires='>=3.6',
'Development Status :: 4 - Beta', classifiers=[
'Environment :: Plugins', 'Development Status :: 4 - Beta',
'Intended Audience :: Developers', 'Environment :: Plugins',
'License :: OSI Approved :: MIT License', 'Intended Audience :: Developers',
'Operating System :: OS Independent', 'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3', 'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.8',
'Topic :: Software Development :: Libraries :: Python Modules', 'Programming Language :: Python :: 3.9',
'Topic :: Text Editors :: Integrated Development Environments (IDE)', 'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities', 'Topic :: Text Editors :: Integrated Development Environments (IDE)',
'Typing :: Typed', 'Topic :: Utilities',
], 'Typing :: Typed',
extras_require={ ],
'testing': [ extras_require={
'pytest<6.0.0', 'testing': [
'docopt', 'pytest<6.0.0',
], 'docopt',
}, ],
) 'qa': [
'flake8==3.8.3',
'mypy==0.782',
],
},
)