diff --git a/docs/docs/development.rst b/docs/docs/development.rst index f723162..1f6f47f 100644 --- a/docs/docs/development.rst +++ b/docs/docs/development.rst @@ -29,10 +29,10 @@ To run the tests for all supported Python versions:: tox -If you want to test only a specific Python version (e.g. Python 2.7), it's as +If you want to test only a specific Python version (e.g. Python 3.9), it's as easy as:: - tox -e py27 + tox -e py39 Tests are also run automatically on `Travis CI `_. diff --git a/parso/cache.py b/parso/cache.py index 324f82a..cdce613 100644 --- a/parso/cache.py +++ b/parso/cache.py @@ -141,16 +141,9 @@ def load_module(hashed_grammar, file_io, cache_path=None): def _load_from_file_system(hashed_grammar, path, p_time, cache_path=None): cache_path = _get_hashed_path(hashed_grammar, path, cache_path=cache_path) try: - try: - if p_time > os.path.getmtime(cache_path): - # Cache is outdated - return None - except OSError as e: - if e.errno == errno.ENOENT: - # In Python 2 instead of an IOError here we get an OSError. - raise FileNotFoundError - else: - raise + if p_time > os.path.getmtime(cache_path): + # Cache is outdated + return None with open(cache_path, 'rb') as f: gc.disable() diff --git a/parso/python/tokenize.py b/parso/python/tokenize.py index 39b645d..2a7774a 100644 --- a/parso/python/tokenize.py +++ b/parso/python/tokenize.py @@ -48,21 +48,8 @@ BOM_UTF8_STRING = BOM_UTF8.decode('utf-8') _token_collection_cache = {} -if sys.version_info.major >= 3: - # Python 3 has str.isidentifier() to check if a char is a valid identifier - is_identifier = str.isidentifier -else: - # Python 2 doesn't, but it's not that important anymore and if you tokenize - # Python 2 code with this, it's still ok. It's just that parsing Python 3 - # code with this function is not 100% correct. - # This just means that Python 2 code matches a few identifiers too much, - # but that doesn't really matter. - def is_identifier(s): - return True - -def group(*choices, **kwargs): - capture = kwargs.pop('capture', False) # Python 2, arrghhhhh :( +def group(*choices, capture=False, **kwargs): assert not kwargs start = '(' @@ -555,7 +542,7 @@ def tokenize_lines(lines, version_info, start_pos=(1, 0), indents=None, is_first m = re.match(r'[ \f\t]*$', line[:start]) if m is not None: yield from dedent_if_necessary(m.end()) - if is_identifier(token): + if token.is_identifier(): yield PythonToken(NAME, token, spos, prefix) else: yield from _split_illegal_unicode_name(token, spos, prefix) diff --git a/parso/python/tree.py b/parso/python/tree.py index d9d836b..98d4de8 100644 --- a/parso/python/tree.py +++ b/parso/python/tree.py @@ -310,10 +310,6 @@ class _StringComparisonMixin(object): return self is other - def __ne__(self, other): - """Python 2 compatibility.""" - return not self.__eq__(other) - def __hash__(self): return hash(self.value)