Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up khan-linter to be python3-only. #42

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Conversation

csilvers
Copy link
Member

Summary:

Now that we're on python3 everywhere, we don't need six anymore. Or the vendored/py2 directory.

I also changed all our shebang lines to say python3 explicitly,
rather than python. This isn't really needed, but some folks don't
even have a /usr/bin/python on their machine, only /usr/bin/python3!
And we might as well be clear.

While testing this, I discovered a few lint errors that are new to new
versions of python, that I cleaned up. I also discovered that the
vendored pyflakes we have is too old for modern pythons, so I updated
it, and also mccabe while I was at it.

Issue: https://khanacademy.slack.com/archives/C02NMB1R5/p1710546934835669

Test plan:

./runlint_test.py

Now that we're on python3 everywhere, we don't need `six` anymore.  Or the `vendored/py2` directory.

I also changed all our shebang lines to say `python3` explicitly,
rather than `python`.  This isn't really needed, but some folks don't
even have a /usr/bin/python on their machine, only /usr/bin/python3!
And we might as well be clear.

While testing this, I discovered a few lint errors that are new to new
versions of python, that I cleaned up.  I also discovered that the
vendored pyflakes we have is too old for modern pythons, so I updated
it, and also mccabe while I was at it.

Issue: https://khanacademy.slack.com/archives/C02NMB1R5/p1710546934835669

Test plan:
./runlint_test.py
@csilvers csilvers self-assigned this Mar 18, 2024
@csilvers csilvers requested a review from a team March 18, 2024 18:22
Copy link
Member

@MiguelCastillo MiguelCastillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems very reasonable to me. Thanks for doing this cleanup!

@@ -1,5 +1,3 @@
#!/usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! Presumably some refactor removed main and forgot to clean this up. Did you need to chmod? Im assuming it had the binary bit given it had a shebang.

@@ -158,7 +155,7 @@ def _extended_fnmatch_compile(pattern):

# If the code below this line has horrible syntax highlighting, check
# this out: http://stackoverflow.com/questions/13210816/sublime-texts-syntax-highlighting-of-regexes-in-python-leaks-into-surrounding-c
_METACHAR_RE = re.compile(r'[[*?!]')
_METACHAR_RE = re.compile(r'[*?![]')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard to tell which way is more readable.

@@ -822,7 +819,7 @@ def main(files_and_directories,
except Exception:
_get_logger().error(u"ERROR linting %r with %s:\n%s" % (
files, type(lint_processor),
traceback.format_exc().decode('utf-8')))
traceback.format_exc()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cant keep track of what needs .decode('utf-8') anymore. 😅

@MiguelCastillo
Copy link
Member

@csilvers let me know if Im blocking you from getting this one out the door :)

@csilvers
Copy link
Member Author

csilvers commented Apr 3, 2024

@csilvers let me know if Im blocking you from getting this one out the door :)

Nope! I'm just using it locally for a while to make sure there are no hidden problems before I land it.

@csilvers csilvers merged commit b195476 into master Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants