Does pants project follow any Python style guide?
# general
f
Does pants project follow any Python style guide?
h
Sort of. It’s not very fleshed out. https://www.pantsbuild.org/styleguide.html
f
The last commit for the pylint was 7 years ago.
h
Good find! We do have a couple of other ways we enforce style by running
./pants fmt ::
, which for example calls isort. But I think there are opportunities to make the style more consistent, through a mix of more tooling like auto-formatters and expanding our style guide
Is there anything in particular you’d like to see added or would like to see improved with style guide / linting / formatting? Or more of a general observation?
f
I feel some of the codes are really hard to read. For instance, this part https://github.com/pantsbuild/pants/blob/272b0a5/src/python/pants/build_graph/build_file_parser.py#L74-L88 is too many level of nesting for such a simple function.
👍 1
It should be broken into smaller parts.
I can share the pylintrc I wrote for my company
Not sure if it going to be usable here.
h
There are parts that I think we could probably incorporate! That’d be great.
We’re also hoping MyPy / type hints will make the code base a bit easier to read
a
+1 to all of that, plus the v2 engine allows flattening out deeply nested logic via dependency injection
h
“allows flattening out deeply nested logic via dependency injection” tbh, dependency injection sounds a bit scarier to me than deeply nested logic
a
in the native backend it's used so that the logic of creating a compiler and linker setup that works on every system is contained in
native_toolchain.py
and that is a massive win imho
b
I'm always weary of pylint, I prefer the softer defaults of flake8