Skip to content

More OSS cleanup#31

Merged
akshayjshah merged 20 commits intomainfrom
ajs/cleanup
Jul 10, 2023
Merged

More OSS cleanup#31
akshayjshah merged 20 commits intomainfrom
ajs/cleanup

Conversation

@akshayjshah
Copy link
Copy Markdown
Contributor

This PR does some more housekeeping before we make the project public. Most notably, it

  • explicitly orders buf generate and license-header, so that make -j4 generate doesn't remove all the licenses.
  • installs Python packages from the lockfile, for more reproducible builds.
  • installs development tools into the virtualenv rather than installing them system-wide.
  • uses the Makefile for linting and formatting in CI.
  • tightens the static analysis configuration and fixes or bypasses errors.

Hopefully these changes are relatively uncontroversial! If anything looks off, let's discuss next week.

Recipe dependencies are run in dependency order, but otherwise don't
have any guaranteed ordering. To make sure that `make -j 4 generate`
retains license headers, we need to explicitly invoke `buf generate`,
then add license headers.

(Recursive make is generally evil, but this simple use case is innocuous
enough.)
Add the comments so that user-facing Make targets are included in `make
help`.
Especially with type hints, modern Python most commonly uses 120-char
lines. This is also the default when using Hatch to create new projects.
Change the Makefile and Pipfile to install lint and formatting tools in
the virtual environment, rather than dropping them into the host system.
Along the way, tighten the lint settings, add a Make target for linting,
and unify the target for unit and integration tests.
Python developers often don't have Go or make installed, so they may not
be able to use the Makefile without some additional guidance.
Our license header tool and black don't agree about whether comment-only
__init__.py files should have a trailing newline or now. Refactor the
Makefile to stay DRY, but allow black to own the final formatting
decisions.
Manually use isort to resort imports, considering the `protovalidate`
and `buf` modules to be first-party code. This is a pre-factoring: later
in this stack of commits, we'll automate this sort with ruff.
Python style is to use `snake_case` for function and method names.
Later in this stack of commits, we'll enforce this with `ruff`.
Fix errors in constraint.py (bypassing spurious ones). Later in this
stack of commits, ruff will require these fixes.
Bypass some spurious warnings in string_format.py.
Bypass spurious lint errors in validator.py.
Configure ruff to catch a wider variety of unidiomatic and error-prone
patterns.
There's no reason to use the wordy xUnit-style `unittest`: we're using
`pytest`, which supports a more Pythonic approach.
Use the Makefile in CI, rather than scripting directly in the YAML
files. Also, ensure that the Go compiler is up-to-date in CI.
Copy link
Copy Markdown
Contributor

@buildbreaker buildbreaker left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@elliotmjackson elliotmjackson left a comment

Choose a reason for hiding this comment

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

it all looks straight forward to me

@akshayjshah akshayjshah merged commit 2732cbf into main Jul 10, 2023
@akshayjshah akshayjshah deleted the ajs/cleanup branch July 10, 2023 18:10
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.

3 participants