-
-
Notifications
You must be signed in to change notification settings - Fork 525
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
[#826] switch to source layout #827
Conversation
tox.ini
Outdated
@@ -115,4 +115,4 @@ include_trailing_comma = True | |||
force_grid_wrap = 0 | |||
line_length = 99 | |||
known_first_party = tox | |||
known_third_party = pkg_resources,pluggy,py,pytest,setuptools,six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asottile I think this is a false positive of the isort plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it assumes a specific layout. PRs welcome, the missing bits are to set the application directories:
For example, here's how reorder_python_imports
handles this:
https://github.com/asottile/reorder_python_imports/blob/794f0498340ab3adbef443431993f8a8b2046da7/reorder_python_imports.py#L405-L411
You'll want:
args: [--application-directories, src]
once seed-isort-config
supports that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if you want to fix this or if you want me to fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm caught up now with other stuff, so if you can fix it that's cool 👍
Here ya go: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8a1d348..3469cf6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -6,9 +6,10 @@ repos:
args: [--line-length=99, --safe]
python_version: python3.6
- repo: https://github.com/asottile/seed-isort-config
- rev: v0.1.0
+ rev: v1.0.0
hooks:
- id: seed-isort-config
+ args: [--application-directories, src]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
hooks:
diff --git a/tox.ini b/tox.ini
index 548f602..9acd122 100644
--- a/tox.ini
+++ b/tox.ini
@@ -115,4 +115,4 @@ include_trailing_comma = True
force_grid_wrap = 0
line_length = 99
known_first_party = tox
-known_third_party = pkg_resources,pluggy,py,pytest,setuptools,six,tox
+known_third_party = pkg_resources,pluggy,py,pytest,setuptools,six |
Codecov Report
@@ Coverage Diff @@
## master #827 +/- ##
======================================
- Coverage 95% 92% -4%
======================================
Files 11 13 +2
Lines 2320 2414 +94
Branches 0 428 +428
======================================
+ Hits 2212 2214 +2
- Misses 108 124 +16
- Partials 0 76 +76 |
tox.ini
Outdated
@@ -103,7 +103,7 @@ source = tox | |||
{toxworkdir}/pypy*/site-packages/tox | |||
|
|||
[pytest] | |||
addopts = -rsxX -vvv --showlocals | |||
addopts = -rsxX --showlocals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok :)
setup.py
Outdated
@@ -1,7 +1,8 @@ | |||
import io | |||
import sys | |||
|
|||
import setuptools | |||
from setuptools import __version__ as setuptools_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the connection to switching to src/ layout here? Is that some name shadowing thing?
Rá, pytest wins the race! pytest-dev/pytest#3513 😸 |
@nicoddemus the reason that's the case is cause I did not figure out yet how to merge coverage files in between interpreters, will probably do it tomorrow when I have some time for that. As I see pytest does not do that 🤔 |
you need to run coverage with https://coverage.readthedocs.io/en/coverage-4.5.1/config.html#paths E.g.: |
@anthrotype I know but pytest-cov does some path mangling here and there which makes is more challenging, been down that path a few times. |
@gaborbernat I see. I remember I also tried once to do it with pytest-cov but then gave up and decided to run pytest as |
c42c7dc
to
0580fe2
Compare
37c55d0
to
911e704
Compare
@nicoddemus managed to nail down things now; tox is not too far behind! @obestwalter @asottile please review and we can merge 👍 |
Awesome, great work! 😁 |
tox.ini
Outdated
@@ -12,47 +12,60 @@ skip_missing_interpreters = true | |||
|
|||
[testenv] | |||
description = run the tests with pytest under {basepython} | |||
setenv = COVERAGE_FILE={toxworkdir}/.coverage.{envname} | |||
setenv = VIRTUALENV_DOWNLOAD = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've usually seen this written as VIRTUALENV_NO_DOWNLOAD=1
tox.ini
Outdated
passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_* | ||
deps = setuptools >= 29.0.0 | ||
setuptools_scm >= 2.0.0, < 3 | ||
wheel >= 0.31.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you set --no-download,
, but then ask for an upgrade of wheel
/ setuptools
? (why not just allow virtualenv to do that for you at this point?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to do with the index URL used. By default virtualenv uses PyPi. This way the tox config adheres too whatever the user has configured; e.g. value from PIP_INDEX_URL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtualenv
respects PIP_INDEX_URL
as well (it's actually just invoking pip
under the hood)
either way, I don't think this boilerplate is helping you solve this issue so let's drop this or move it to another PR
tox.ini
Outdated
commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -bhtml | ||
|
||
|
||
[testenv:fix-lint] | ||
description = run static analysis and style check using flake8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, description isn't exactly right
description = combine coverage data and create reports | ||
deps = coverage | ||
description = [run locally after tests]: combine coverage data and create report; | ||
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should DIFF_AGAINST
be in passenv
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well spotted, fixed
tox.ini
Outdated
basepython = python3.6 | ||
passenv = {[testenv]passenv} | ||
HOMEPATH | ||
# without PROGRAMDATA cloning using git for Windows will fail with an | ||
# `error setting certificate verify locations` error | ||
PROGRAMDATA | ||
extras = lint | ||
description = run static analysis and style check using flake8 | ||
changedir = {toxinidir} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, pre-comit
will cd
right back to the repository root, not sure this is useful
tox.ini
Outdated
@@ -90,21 +106,21 @@ max-line-length = 99 | |||
ignore = E203, W503 | |||
|
|||
[coverage:run] | |||
omit = tox/__main__.py | |||
branch = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
branch coverage is useful! please don't turn it off!
source = src/tox | ||
.tox/*/lib/python*/site-packages/tox | ||
.tox/*/Lib/site-packages/tox | ||
.tox/pypy*/site-packages/tox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is by far my least favorite part of moving to a src
directory, the coverage reports become unreadable :(
we've used this script or a derivative of it to try and make this more sane (it combines the coverage data from site-packages over top the local directory)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, combining the data is still fine (e.g. tox -e py27,coverage
); only the pytest run one is messed up; I would prefer to fix this upstream instead 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise looks good
while you're at it, can probably add skip_install = True
to the pre-commit env
tox.ini
Outdated
basepython = python3.6 | ||
passenv = {[testenv]passenv} | ||
HOMEPATH | ||
# without PROGRAMDATA cloning using git for Windows will fail with an | ||
# `error setting certificate verify locations` error | ||
PROGRAMDATA | ||
DIFF_AGAINST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, added this to the wrong testenv, needs to be in the coverage
testenv
things now look great 👍 so I'll go ahead and merge it. 🙊 sorry for people with PRs for the merge conflicts |
a POC of it at least