Skip to content

CI: Run flake8 (plus various plugins) during tests #111

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

Merged
merged 9 commits into from
Mar 26, 2019

Conversation

nicoonoclaste
Copy link
Collaborator

@nicoonoclaste nicoonoclaste commented Feb 4, 2019

@nicoonoclaste nicoonoclaste mentioned this pull request Feb 4, 2019
@pathunstrom
Copy link
Collaborator

How do you run these tests in a Windows environment?

@pathunstrom
Copy link
Collaborator

Additionally, I am strongly against a linter as a dev requirement.

@nicoonoclaste
Copy link
Collaborator Author

@pathunstrom The commands moved from being in .travis.yml (which contains Bash commands) to being in a shell script; in neither case can they be readily invoked in a (native) Windows environment, so that's not a regression.

@nicoonoclaste
Copy link
Collaborator Author

I am strongly against a linter as a dev requirement.

Could you provide a rationale?

@pathunstrom
Copy link
Collaborator

I guess last quest, you mention mutable defaults, but I don't see any such changes in the code, am I missing them?

@nicoonoclaste
Copy link
Collaborator Author

@pathunstrom I found 2 at a quick glance, can't recall offhand if there were more.
You can check commit 36976d9, which introduced that lint check (it's mentioned in the commit message).

@AstraLuma
Copy link
Member

Based on discord discussion, let's break this up.

I'm willing to accept all of the source changes made by the formatting in a PR. I don't disagree with any of it.

However, we need to have further discussions on the tooling changes. I think that test.sh is good (although it needs a matching .bat), I think we agree that some level of lint is good, and that having that lint as part of the local development process as simply as possible is good.

What needs further discussion is what the exact lint ruleset should be.

@nicoonoclaste
Copy link
Collaborator Author

nicoonoclaste commented Feb 4, 2019

[test.sh] needs a matching .bat

Can this either happen in a follow-up PR or can one of you commit it to this branch?
There's no Windows-based CI here, and I don't have any Windows system to test with.

@nicoonoclaste
Copy link
Collaborator Author

What needs further discussion is what the exact lint ruleset should be.

I think we ought to iterate as false-positives come up?
Every single flake8 plugin that was added here found issues, so they are arguably useful, and I find it hard to reason about single lint rules in the abstract (though you two probably have more experience with Python linters)

@nicoonoclaste
Copy link
Collaborator Author

I just rebased so CI would rerun with the fix from #112

@nicoonoclaste nicoonoclaste force-pushed the qa/flake8 branch 2 times, most recently from c6e2afa to 40a0269 Compare February 4, 2019 19:29
@nicoonoclaste
Copy link
Collaborator Author

The latest commit (40a0269) fixed the PyPy build: test.sh was accidentally attempting to run mypy under pypy3.

@nicoonoclaste
Copy link
Collaborator Author

nicoonoclaste commented Feb 24, 2019

What needs further discussion is what the exact lint ruleset should be.

It's been almost a month, and there's been no discussion, and no response to my comments.

@nicoonoclaste
Copy link
Collaborator Author

The CI issue seems to be the same issue #112 should have fixed :(

@nicoonoclaste
Copy link
Collaborator Author

Confirmed: we have attrs 17.3.0 installed along pytest 3.10.1 even though pytest requires attrs >= 17.4.0 since version 3.5.0.

nicoonoclaste added a commit to nicoonoclaste/ppb-vector that referenced this pull request Feb 24, 2019
This should mitigate pip's inability to deal with [versionned dependencies],
and will hopefully stop it from continuously breaking CI.

[versionned dependencies]: ppb#111 (comment)
@nicoonoclaste
Copy link
Collaborator Author

OK, looks like #114 fixed the CI issue (hopefully for good...)

@nicoonoclaste
Copy link
Collaborator Author

Ping?

@nicoonoclaste
Copy link
Collaborator Author

@astronouth7303 @pathunstrom I did what I suggested and split off the actual changes into #116.
This branch contains #116, plus the commits that enforce those lints in CI.

@nicoonoclaste nicoonoclaste changed the title CI: Support running tests locally, and run flake8 CI: Run flake8 (plus various plugins) during tests Mar 15, 2019
@nicoonoclaste
Copy link
Collaborator Author

Rebased to solve the merge conflict, and fixed the lints that broke (because I can't write correctly-styled Python unassisted).

@nicoonoclaste
Copy link
Collaborator Author

nicoonoclaste commented Mar 18, 2019

So, about that discussion on which lint rules are desirable, you said it's needed but all we got is me monologuing for a month-and-a-half. What will it take to make it happen?

@AstraLuma
Copy link
Member

Looks like hypothesis might have found a bug? Care to investigate?

@nicoonoclaste
Copy link
Collaborator Author

@astronouth7303 Was the failure you mentioned one of the things that we fixed recently?

@AstraLuma
Copy link
Member

I can't find the CI that's in reference to, so I have no idea.

@nicoonoclaste
Copy link
Collaborator Author

Rebased again, to deal with merge conflicts.

@AstraLuma
Copy link
Member

Just going for it.

bors r+

bors bot added a commit that referenced this pull request Mar 26, 2019
111: CI: Run flake8 (plus various plugins) during tests r=astronouth7303 a=nbraud

- Superset of #116 :
  - [x] Extract tests & QA tools execution to a `tests.sh` script.
  - [x] Reorder execution order to fail faster.
  - [x] Eliminate mutable default parameters (found by `flake8-bugbear`)
  - [x] Uniformize the ordeer of `import` lines.
  - [x] Uniformize the use of trailing commas

- Automatically enforce the things that were fixed in #116 :
  - [x] Check basic lints with `flake8`
  - [x] Check for PEP 8 [naming conventions](https://www.python.org/dev/peps/pep-0008/#naming-conventions)
    This caught an issue that should have been fixed in #85 (a scalar named `l`); this likely happened because the test in question was added concurrently to #85.
  - [x] Enable `flake8-bugbear` and its “opinionated” checks
    This caught a number of instances where mutable data was used in default parameters.
  - [x] Check for trailing commas where useful
  - [x] Enforce a consistent import order

[PEP 8]: https://www.python.org/dev/peps/pep-0008/
[`black`]: https://github.com/ambv/black

Co-authored-by: Nicolas Braud-Santoni <[email protected]>
@bors
Copy link
Contributor

bors bot commented Mar 26, 2019

Build failed

  • lint

@nicoonoclaste
Copy link
Collaborator Author

@astronouth7303 I fixed the lint issues that got introduced into master since the last rebase.

@@ -487,7 +487,7 @@ def truncate(self: Vector, max_length: typing.SupportsFloat) -> Vector:

Note that :py:meth:`vector.scale(max_length) <scale>` is equivalent to
:py:meth:`vector.truncate(max_length) <truncate>` when
:py:meth:`max_length \< vector.length <length>`.
:py:meth:`max_length < vector.length <length>`.
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't render right in Sphinx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ohno. I thought I would dodge the issue by using a unicode < sign, rather than the angled braket ;_;
Fixed with a different symbol O:3

@AstraLuma
Copy link
Member

NERD.

bors r+

bors bot added a commit that referenced this pull request Mar 26, 2019
111: CI: Run flake8 (plus various plugins) during tests r=astronouth7303 a=nbraud

- Superset of #116 :
  - [x] Extract tests & QA tools execution to a `tests.sh` script.
  - [x] Reorder execution order to fail faster.
  - [x] Eliminate mutable default parameters (found by `flake8-bugbear`)
  - [x] Uniformize the ordeer of `import` lines.
  - [x] Uniformize the use of trailing commas

- Automatically enforce the things that were fixed in #116 :
  - [x] Check basic lints with `flake8`
  - [x] Check for PEP 8 [naming conventions](https://www.python.org/dev/peps/pep-0008/#naming-conventions)
    This caught an issue that should have been fixed in #85 (a scalar named `l`); this likely happened because the test in question was added concurrently to #85.
  - [x] Enable `flake8-bugbear` and its “opinionated” checks
    This caught a number of instances where mutable data was used in default parameters.
  - [x] Check for trailing commas where useful
  - [x] Enforce a consistent import order

[PEP 8]: https://www.python.org/dev/peps/pep-0008/
[`black`]: https://github.com/ambv/black

Co-authored-by: Nicolas Braud-Santoni <[email protected]>
@bors
Copy link
Contributor

bors bot commented Mar 26, 2019

Build succeeded

  • docs
  • FreeBSD PYTHON:3.6
  • FreeBSD PYTHON:3.7
  • lint
  • Linux container:python:3.6-slim
  • Linux container:python:3.7-slim
  • macOS PYTHON:3.6.8
  • macOS PYTHON:3.7.2
  • Windows container:python:3.6-windowsservercore-1809
  • Windows container:python:3.7-windowsservercore-1809

@bors bors bot merged commit f594771 into ppb:master Mar 26, 2019
@nicoonoclaste nicoonoclaste deleted the qa/flake8 branch March 27, 2019 11:13
@nicoonoclaste
Copy link
Collaborator Author

@astronouth7303 Guilty as charged <3

@nicoonoclaste
Copy link
Collaborator Author

On one hand, ≨ is a bit of an arcane rune, OTOH I like that it's extra explicit about v.truncate(l) and v.scale_to(l) not being always equivalent when l == v.length (Hypothesis found test vectors such that v.x != 1.0 * v.x 😭 )

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