Commit Graph

16 Commits

Author SHA1 Message Date
Andrew Trick
97b781626f Fix lit test Python/python_lint.swift
./utils/cmpcodesize/cmpcodesize/main.py:20:71: E231 missing whitespace after ','

./utils/round-trip-syntax-test:20:20: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

./utils/round-trip-syntax-test:21:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

I can't find any uses of round-trip-syntax-test, so I don't know if
this fix is correct.
2023-11-17 16:53:49 -08:00
Guillaume Lessard
36d230ed28 [gardening] change an ambiguous variable name
- lowercase-l trips some python lint configurations
2023-01-25 11:06:44 -08:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Alex Hoppen
e7ceabcfde [SwiftSyntax] Decode stdout and stderr in round-trip-syntax-test as UTF-8 2022-03-25 09:07:10 +01:00
Daniel Duan
025079466a [utils] Remove Python 2
The library `six` provides compatibility between Python 2, and 3. It's no
longer necessary once we migrate of Python 2 completely.

Also remove any custom logic for Python 2 (the ones referenced by
a commentanyways).

https://bugs.swift.org/browse/SR-16025
2022-03-20 13:22:04 -07:00
tbkka
421ebd2788 [Python3] Fix "undefined symbol 'unicode'" from python_lint (#33146)
* [Python3] Fix "undefined symbol 'unicode'" from python_lint

This is a little tricky.

Python 2 "unicode" was renamed to "str" in Python 3.

For Python 2 compatibility, we need to use "unicode" in a couple
of places, but that's not defined on Python 3, which causes
python_lint errors (even if the reference is never actually executed).

To workaround this, when running in Python 3, define "unicode"
as a synonym for "str".  This defines the symbol (avoiding the
"undefined symbol" error from python lint) while preserving
the correct functionality on both Python 2 and Python 3.

When we drop Python 2 support (which we should do as soon as
possible), we can drop this workaround and globally replace
"unicode" with "str" to get the right Python 3-only functionality.
2020-07-28 11:47:25 -07:00
Saleem Abdulrasool
96127ca3ce Update round-trip-syntax-test
Try harder to appease the python linter
2020-07-01 13:28:22 -07:00
Saleem Abdulrasool
14f72b7f0e test: appease python linter (NFC) 2020-07-01 10:17:47 -07:00
Saleem Abdulrasool
b9e600b001 test: make round-trip-syntax-test Python 3 friendly
Make the `round-trip-syntax-test` tool Python 3 friendly by tweaking the
open modes and using `reduce` from `functools` as it has been removed in
Python 3.
2020-07-01 10:15:18 -07:00
Ben Langmuir
62154093c0 Fix pylint warning about indentation width 2019-02-15 11:52:25 -08:00
Ben Langmuir
d02c52124d Speed up roundtrip syntax tests
Running the unified diff is really slow, so first check if the strings
are identical. Speeds up the roundtrip stdlib test by 8x on my machine.
2019-02-15 10:45:29 -08:00
Saleem Abdulrasool
7d07ae4192 utils: port round-trip-syntax-test to windows
Use python's builtin diff rather than invoking `/usr/bin/diff` which
does not exist on Windows.  Decode the content into UTF-8 before
processing it for the diff as the file reading will give us UTF-16
content on Windows.
2019-01-15 19:47:55 -08:00
Rintaro Ishizaki
1615a6746f [libSyntax] Fix round-trip-syntax-test script
was always success because of logic error in the script.
2017-12-09 14:48:21 +09:00
Hugh Bellamy
ad4b338062 Fix python lint failures now not excluded as we provide custom exclusions
Looks like flake8 enables other rules when you add something to the
exclusion list. We added W291
2017-03-27 12:31:56 +07:00
Hugh Bellamy
8671854674 Properly python lint remaining files 2017-03-23 14:06:46 +07:00
David Farler
71346dc5c1 [Syntax] Add round-trip syntax test driver and stdlib roundtrip test 2017-02-17 12:57:04 -08:00