Open rsb-23 opened 8 months ago
Thanks for PR .. why flake8? .. Thought we will use pylint https://github.com/py-vobject/vobject/discussions/27#discussioncomment-8746456 .. to run tests locally we need a solution like running-tests ?
This is great, thank you!
Also, have a look at https://github.com/da4089/vobject/tree/dev-flake8, where I've been working on similar area.
Also, we need to ensure that the resulting code is compatible with Python 2.7 for the 0.9.x releases still. I think I've managed to retain that, but I notice your comment that this is Python3.7+ only?
Thanks for PR .. why flake8? .. Thought we will use pylint #27 (reply in thread) .. to run tests locally we need a solution like running-tests ?
I've been experimenting in my branch with using both, TBH. pylint seems to warn about a lot more stuff than flake8, but maybe both is ok?
I still haven't got to a point of producing useful reporting artifacts from any of these either.
Thanks for PR .. why flake8? .. Thought we will use pylint #27 (reply in thread) .. to run tests locally we need a solution like running-tests ?
I think the best solution for local execution is to put the configuration into pyproject.toml
so that it's always consistent, and then perhaps just documentation (like the tests) which says something like:
To run code quality analysis tools, you can simply execute them directly like:
$ flake8 vobject
$ pylint vobject
in the project's home directory.
and then try to make sure the config options in pyproject.toml are universally useful. See the branch above for my first draft attempt at this.
See the branch above for my first draft attempt at this.
LGTM at first sight .. give me some more time ..
ensure that the resulting code is compatible with Python 2.7 for the 0.9.x releases still. .. and then try to make sure the config options in pyproject.toml a
Is it compatible with 2.7?
perhaps just documentation (like the tests) which says something like ..
Doc should include instructions to build up a virtualenv / otherwise the local test runs and package versions are highly dependent on the individual Python setup of the developer.
I still haven't got to a point of producing useful reporting artifacts from any of these either.
Not sure I fully understand what you mean by / what you expect .. can you explain it to me in more detail?
I hope I have time next weekend to implement a PR that demonstrates what I have in mind ..
I've pushed a change to my https://github.com/da4089/vobject/tree/dev-flake8 branch that:
I think we should be able to safely use this on the 0.9.x code without it breaking stuff like u"foo" strings.
Thanks for PR .. why flake8? .. Thought we will use pylint #27 (reply in thread) .. to run tests locally we need a solution like running-tests ?
pre-commit run -all
for all files and (mostly) git add . && pre-commit run
for just modifed files.
These command runs all linters together instead of running individually.Thanks for PR .. why flake8? .. Thought we will use pylint #27 (reply in thread) .. to run tests locally we need a solution like running-tests ?
I think the best solution for local execution is to put the configuration into
pyproject.toml
so that it's always consistent, and then perhaps just documentation (like the tests) which says something like:To run code quality analysis tools, you can simply execute them directly like: $ flake8 vobject $ pylint vobject in the project's home directory.
and then try to make sure the config options in pyproject.toml are universally useful. See the branch above for my first draft attempt at this.
setup.cfg
instead. Will move the configs to .toml file.pre-commit run -all
can be used to run all linters at once, locally.Thinking ... maybe I should create a branch off master and we can merge this PR into that, and my branch over that, and then sort of any remaining issues before merging the whole lot into master.
Does that sound ok to you?
@da4089 I lost the overview about the python releases you want support ..
In the commit 992b8b70@dev-lint you targeting Python2.7 ..
.. but in github CI we test starting with py3.7:
Do you plan to add new branch later (after we merged linted code)? A branch for the 0.9.x releases?
- For running locally, I use
pre-commit run -all
for all files and (mostly)git add . && pre-commit run
for just modifed files. These command runs all linters together instead of running individually.
@rsb-23 I'm new to pre-commit but it looks interesting .. one thing I miss: we can't combine the linting test/tools (from pre-commit) with other tests needed to be run locally before create a commit / e.g the unit tests (see python tests.py) .. or is there a chance to add unit and other tests from the project to the .pre-commit-config.yaml
?
I would like 0.9.x to continue to support 2.7.
I wanted to do some cleanup before splitting, so it's easier to to share patches across the two branches.
master will become 1.0 and support Python 3 only.
I'd like to make the split pretty soon.
I'm new to pre-commit too. I don't have a full understanding of what's possible yet.
I would like 0.9.x to continue to support 2.7. I wanted to do some cleanup before splitting,
OK now I got you :) .. but then I think we should first go a step back ...
and add back the py2.7 to the github CI. Second we need a way to test code in py2.7 locally (I have https://asdf-vm.com/ in mind).
Reasons why we need to test Py 2.7 (before branching):
The good news: we only need the code changes before we split a 0.9.x branch ... there is no need to run lint tools in the 0.9.x: if we only transfer patches to the 0.9.x branch from the master, then we don't necessarily need a lint tool in the 0.9.x branch (further I expect that a 0.9.x branch will die soon).
I'm new to pre-commit too. I don't have a full understanding of what's possible yet.
This is the second point that makes me ponder: in the dev-lint branch we now have 3 different test & lint approaches / tools
The decision for or against pre-commit hooks should not be made before the 0.9.3 branch point has been created. In py2.7 this tool will probably not work.
Furthermore, the decision should be carefully considered. The method of hooking the tests into the (git) pre-commit hooks is discussed controversial: https://www.reddit.com/r/git/comments/16ke0xa/arguments_for_and_against_precommit_hooks/
The tools don't run in Python 2.7. I tried in a venv without success.
@return42 Thanks for all the details, I would have shared the same.
pytest
or manually configure unittest
. Also it won't be as effective and easy as in CI triggered on PR.Unittest / pytest
along with coverage
module are generally used in CI to generate test report and apply minimum coverage criteria. My setup idea:
pyproject.toml
for the configurations like line-length (its not consistent as of now, I think 100 is good.), exclusions, etc.git add . && pre-commit run
. Each hook can be run alone too.unittest + coverage
for unit tests and report generation.@da4089 About code-cleanup: the source files in this project are using CRLF (\r\n
) to denote the newline character, while Unix-like systems represent it using LF (\n
). Do you want to stay with CRLF or do you want to switch to LF?
Be warned: The switch to LF will touch ever single file / conflict with all forks and branches.
@da4089 About code-cleanup: the source files in this project are using CRLF (
\r\n
) to denote the newline character, while Unix-like systems represent it using LF (\n
). Do you want to stay with CRLF or do you want to switch to LF?
We should switch the repo to LF, and those working on Windows should use the automagic LF/CRLF translation built into git.
Be warned: The switch to LF will touch ever single file / conflict with all forks and branches.
Perhaps you could create a GitHub issue for this, and we'll pick a good moment to do it when all branches are merged?
One other approach might be to create the 0.9.x branch soon (more or less now).
The changes resulting from eg. black, and fixes to lint-identified issues should then be applied first to the 0.9.x branch, and then merged to master.
We could leave 0.9.x branch using setup.py, without pre-commit, and maybe just running the unit tests. master could get the pyproject.toml migration, pre-commit, and all the automation.
It's more work to merge all the formatting, etc, changes through both branches, but the tooling setup might be better this way?
We should switch the repo to LF,
OK ..
One other approach
give me a little more time / I'm currently working on a commit line (thats why I ask al thes questions :) .. hopefully tomorrow I can present you a way that fulfill all your request :)
Be warned: The switch to LF will touch ever single file / conflict with all forks and branches.
I have to correct .. only some files have CRLF ..
Be warned: The switch to LF will touch ever single file / conflict with all forks and branches.
Perhaps you could create a GitHub issue for this, and we'll pick a good moment to do it when all branches are merged?
We can add this hook. And can also add this to CI for PR too.
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
hopefully tomorrow I can present you a way that fulfill all your request :)
it's more than I expected / I'm still working on it ... there's a preview available in a PR I created in my fork for testing purposes.
⚠️ Python compatibility 3.7 and above only.
Checks :
Changes :
isort, black, flake8
linters.TODO
andnoqa
for other cases.xrange
withrange
function in win32tz.py🙏🏼 Changes are mostly double quotes, whitespace, indentation and sort order. Apologies, as its too many changes in single PR.