diff --git a/conftest.py b/conftest.py index 8f297a5..4d0b927 100644 --- a/conftest.py +++ b/conftest.py @@ -56,7 +56,7 @@ def pytest_generate_tests(metafunc): metafunc.parametrize('version_ge_py38', sorted(ge38)) -class NormalizerIssueCase(object): +class NormalizerIssueCase: """ Static Analysis cases lie in the static_analysis folder. The tests also start with `#!`, like the goto_definition tests. @@ -88,7 +88,7 @@ def pytest_configure(config): #root.addHandler(ch) -class Checker(): +class Checker: def __init__(self, version, is_passing): self.version = version self._is_passing = is_passing diff --git a/parso/cache.py b/parso/cache.py index c0bb479..d96bb7b 100644 --- a/parso/cache.py +++ b/parso/cache.py @@ -102,7 +102,7 @@ def _get_cache_clear_lock(cache_path=None): parser_cache: Dict[str, Any] = {} -class _NodeCacheItem(object): +class _NodeCacheItem: def __init__(self, node, lines, change_time=None): self.node = node self.lines = lines diff --git a/parso/file_io.py b/parso/file_io.py index a9fcfe3..722e7ba 100644 --- a/parso/file_io.py +++ b/parso/file_io.py @@ -1,7 +1,7 @@ import os -class FileIO(object): +class FileIO: def __init__(self, path): self.path = path diff --git a/parso/normalizer.py b/parso/normalizer.py index 5c5d2b9..fddb88f 100644 --- a/parso/normalizer.py +++ b/parso/normalizer.py @@ -105,7 +105,7 @@ class Normalizer(metaclass=_NormalizerMeta): return decorator -class NormalizerConfig(object): +class NormalizerConfig: normalizer_class = Normalizer def create_normalizer(self, grammar): @@ -115,7 +115,7 @@ class NormalizerConfig(object): return self.normalizer_class(grammar, self) -class Issue(object): +class Issue: def __init__(self, node, code, message): self.code = code """ @@ -145,7 +145,7 @@ class Issue(object): return '<%s: %s>' % (self.__class__.__name__, self.code) -class Rule(object): +class Rule: code: int message: str diff --git a/parso/parser.py b/parso/parser.py index a7cc6fa..3b25f35 100644 --- a/parso/parser.py +++ b/parso/parser.py @@ -73,7 +73,7 @@ class Stack(list): return list(iterate()) -class StackNode(object): +class StackNode: def __init__(self, dfa): self.dfa = dfa self.nodes = [] @@ -98,7 +98,7 @@ def _token_to_transition(grammar, type_, value): return type_ -class BaseParser(object): +class BaseParser: """Parser engine. A Parser instance contains state pertaining to the current token diff --git a/parso/python/diff.py b/parso/python/diff.py index 1863413..ba999fa 100644 --- a/parso/python/diff.py +++ b/parso/python/diff.py @@ -247,7 +247,7 @@ def _update_positions(nodes, line_offset, last_leaf): _update_positions(children, line_offset, last_leaf) -class DiffParser(object): +class DiffParser: """ An advanced form of parsing a file faster. Unfortunately comes with huge side effects. It changes the given module. @@ -514,7 +514,7 @@ class DiffParser(object): yield token -class _NodesTreeNode(object): +class _NodesTreeNode: _ChildrenGroup = namedtuple( '_ChildrenGroup', 'prefix children line_offset last_line_offset_leaf') @@ -589,7 +589,7 @@ class _NodesTreeNode(object): return '<%s: %s>' % (self.__class__.__name__, self.tree_node) -class _NodesTree(object): +class _NodesTree: def __init__(self, module): self._base_node = _NodesTreeNode(module) self._working_stack = [self._base_node] diff --git a/parso/python/errors.py b/parso/python/errors.py index 9cdc9e0..9d28e54 100644 --- a/parso/python/errors.py +++ b/parso/python/errors.py @@ -222,7 +222,7 @@ def _any_fstring_error(version, node): return search_ancestor(node, "fstring") -class _Context(object): +class _Context: def __init__(self, node, add_syntax_error, parent_context=None): self.node = node self.blocks = [] diff --git a/parso/python/pep8.py b/parso/python/pep8.py index 13e17ed..d3eb345 100644 --- a/parso/python/pep8.py +++ b/parso/python/pep8.py @@ -26,7 +26,7 @@ _IMPLICIT_INDENTATION_TYPES = ('dictorsetmaker', 'argument') _POSSIBLE_SLICE_PARENTS = ('subscript', 'subscriptlist', 'sliceop') -class IndentationTypes(object): +class IndentationTypes: VERTICAL_BRACKET = object() HANGING_BRACKET = object() BACKSLASH = object() diff --git a/parso/python/prefix.py b/parso/python/prefix.py index 7fac9fc..c764c46 100644 --- a/parso/python/prefix.py +++ b/parso/python/prefix.py @@ -6,7 +6,7 @@ from parso.python.tokenize import group unicode_bom = BOM_UTF8.decode('utf-8') -class PrefixPart(object): +class PrefixPart: def __init__(self, leaf, typ, value, spacing='', start_pos=None): assert start_pos is not None self.parent = leaf diff --git a/parso/python/token.py b/parso/python/token.py index eda08f1..9b6f4c7 100644 --- a/parso/python/token.py +++ b/parso/python/token.py @@ -3,7 +3,7 @@ from __future__ import absolute_import from enum import Enum -class TokenType(object): +class TokenType: name: str contains_syntax: bool diff --git a/parso/python/tokenize.py b/parso/python/tokenize.py index 896772e..6282275 100644 --- a/parso/python/tokenize.py +++ b/parso/python/tokenize.py @@ -246,7 +246,7 @@ class PythonToken(Token): self._replace(type=self.type.name)) -class FStringNode(object): +class FStringNode: def __init__(self, quote): self.quote = quote self.parentheses_count = 0 diff --git a/parso/python/tree.py b/parso/python/tree.py index 850835d..04fbe71 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -68,7 +68,7 @@ _GET_DEFINITION_TYPES = set([ _IMPORTS = set(['import_name', 'import_from']) -class DocstringMixin(object): +class DocstringMixin: __slots__ = () def get_doc_node(self): @@ -96,7 +96,7 @@ class DocstringMixin(object): return None -class PythonMixin(object): +class PythonMixin: """ Some Python specific utilities. """ @@ -296,7 +296,7 @@ class FStringEnd(PythonLeaf): __slots__ = () -class _StringComparisonMixin(object): +class _StringComparisonMixin: def __eq__(self, other): """ Make comparisons with strings easy. diff --git a/parso/tree.py b/parso/tree.py index ec58ed9..2c7312d 100644 --- a/parso/tree.py +++ b/parso/tree.py @@ -18,7 +18,7 @@ def search_ancestor(node, *node_types): return node -class NodeOrLeaf(object): +class NodeOrLeaf: """ The base class for nodes and leaves. """ diff --git a/test/test_diff_parser.py b/test/test_diff_parser.py index 3f120bc..222236e 100644 --- a/test/test_diff_parser.py +++ b/test/test_diff_parser.py @@ -38,7 +38,7 @@ def _check_error_leaves_nodes(node): return None -class Differ(object): +class Differ: grammar = load_grammar() def initialize(self, code): diff --git a/test/test_normalizer_issues_files.py b/test/test_normalizer_issues_files.py index 03e09ef..0427313 100644 --- a/test/test_normalizer_issues_files.py +++ b/test/test_normalizer_issues_files.py @@ -12,7 +12,7 @@ from parso.utils import python_bytes_to_unicode @total_ordering -class WantedIssue(object): +class WantedIssue: def __init__(self, code, line, column): self.code = code self._line = line diff --git a/test/test_parser_tree.py b/test/test_parser_tree.py index 0964567..0201f7c 100644 --- a/test/test_parser_tree.py +++ b/test/test_parser_tree.py @@ -8,7 +8,7 @@ from parso import parse from parso.python import tree -class TestsFunctionAndLambdaParsing(object): +class TestsFunctionAndLambdaParsing: FIXTURES = [ ('def my_function(x, y, z) -> str:\n return x + y * z\n', {