The Wayback Machine - https://web.archive.org/web/20220604141603/https://github.com/google/jax/pull/1442
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

WIP: Add a pylintrc to make it easire to use linter #1442

Merged
merged 6 commits into from Oct 5, 2019
Merged

Conversation

joaogui1
Copy link
Contributor

@joaogui1 joaogui1 commented Oct 4, 2019

Right now it's just using the same pylintrc as tensor2tensor, I'm trying to tell it to ignore C0103 (since jax doesn't seem to follow PEP8 variable's name guidelines).
Is there anything like a style guide for contributing to jax?

@skye
Copy link
Collaborator

@skye skye commented Oct 4, 2019

There is no style guide, as you can probably tell from looking at the code :)
I'm wary of using tensor2tensor's .pylintrc, because it looks like there's a lot of stuff in there that doesn't apply to us (e.g. ignore=get_references_web.py,get_references_web_single_group.py?), and I think it may be disabling too many checks (e.g. no-member is usually a good one).

I wonder if we should use a minimal .pylintrc that only includes the defaults we're overriding, rather than including everything, which makes it hard to see what's actually relevant.

Here's what I use for myself (I think, I also have all the default options included so it's hard for me to tell what I changed):

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=missing-docstring,
        too-many-locals,
        invalid-name,
        protected-name,
        no-else-return,
        fixme,
        protected-access,
        too-many-arguments,
        blacklisted-name,
        too-few-public-methods,
        unnecessary-lambda,

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member

I've found this useful for finding errors without complaining about our rampant PEP8 violations. What do you think? Wanna give this a try and see if we can start from here?

@joaogui1
Copy link
Contributor Author

@joaogui1 joaogui1 commented Oct 4, 2019

I used yours and added redefined-outer-name and redefined-builtin to the disables and set indentation to 2 spaces. What do you guys think of using yapf with the chromium style? I think using it and this pylintrc could make jax development easier.

@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Copy link
Collaborator

@skye skye Oct 5, 2019

Choose a reason for hiding this comment

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

Can you revert this file for now? I like the idea of auto-formatting, but let's do one thing at a time :)

pylintrc Outdated
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy
indent-string=" "
Copy link
Collaborator

@skye skye Oct 5, 2019

Choose a reason for hiding this comment

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

nit: if you're gonna keep the [MASTER], etc. headings, indent-string goes under [FORMAT]. Or just remove the headings. Also, please put a blank line between the different directives.

@skye
Copy link
Collaborator

@skye skye commented Oct 5, 2019

Looks good except for the minor comments I left, thanks!

I have limited experience with Python formatters, mostly because I think they don't do a great job... looking at the file you formatted, it looks like it creates a lot of unnecessary vertical space, like by breaking up function arguments on separate lines. Maybe there are settings to make it format things more concisely?

@skye
Copy link
Collaborator

@skye skye commented Oct 5, 2019

Just in case you didn't see the other comment, can you revert the lax_numpy.py formatting changes?

@joaogui1
Copy link
Contributor Author

@joaogui1 joaogui1 commented Oct 5, 2019

wow, I hadn't seen it, I will revert it and remove the yapf style file. The only change I will keep on lax is removing the pylint comments since they've been incorporated on pylintrc, ok?

@skye
Copy link
Collaborator

@skye skye commented Oct 5, 2019

Looks great, thanks!

@skye skye merged commit a0bb2c0 into google:master Oct 5, 2019
1 of 2 checks passed
skye added a commit that referenced this issue Oct 8, 2019
This reverts commit a0bb2c0.

Temporarily reverting this to see if it's causing the github workflow failures.
skye added a commit that referenced this issue Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants