-
Notifications
You must be signed in to change notification settings - Fork 137
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
dev: update dependencies, testing, packaging, and linting/formatting #685
dev: update dependencies, testing, packaging, and linting/formatting #685
Conversation
28ae921
to
46edd80
Compare
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 really nice, thank you! I've put a couple of small notes inline and happy for you to merge after you've considered them.
- config: old [setup.cfg, setup.py], new [pyproject.toml] - format/lint: old [black, flake8, isort], new [ruff] - build/publish: old [build, twine], new [flit] - updated github actions and readme accordingly - source changes according to new default formatter and linter rules
- nobody has changed these files since 2011, and they're very incomplete - the docs generated aren't published anywhere - the readme instructions don't work with python 3.8 - sphinx 1.0.7 not compatible with python 3+ - newer sphinx versions have an OS dependency on OpenSSL 1.1.1+ - updated readme to refer to useful resources and current docs state
- mostly error handling, unused variables
- mostly mutable classvars, unnecessary noqa comments, list unpacking
- unnecessary calls to list() or dict(), redundant comprehensions
- unnecessary placeholders, unnecessary range starts (0), dict.values() - re-order ruff calls since `check` doesn't auto-format
- collapsible else-ifs, collapsible multiple comparisons
- use of assert, use of ElementTree, unchecked URL scheme
- use type-able NamedTuple, raise accurate errors, log exception TBs
- UP009 utf8-encoding-declaration unnecessary for python 3
- UP031 printf-string-formatting replace percent-formats with f-strings
- nose 1.3.7 is very old and not using any advanced test features that would require a 3rd party test library like nose2 or pytest - default pattern is test_* for runner to pick up TestCases
- remove redundant mode/encoding args - simplify unittest import in test_bugs.py
- xls2json_backends.py: both XLS and XLSX open and read the respective files, do processing, then close the file. But if an error occurs during processing then the file is left open. A ResourceWarning is raised when python cleans up the file handle. The ResourceWarning is visible during tests because test libraries remove the normal suppression of warnings during test runs. So normally a user probably wouldn't see it. The fix is to make sure the workbook object and file are cleaned up and closed with a contextmanager + try-except block. - test_bugs.py: fixed test that had been broken for a while. It was not being executed by nose test runner for some reason. After converting tests to unittest, it ran and failed. After doing some git archaeology it seems that the 3rd warning that was expected was one about Google Sheets not supporting certain file names, but while that warning was later removed, the test was not updated. The 2nd is commented on. - fixed strange string concatentation on the same line e.g. "a" "b".
- nose tests were not running this test for a while. The changes are: - secondary instances / itemsets replacing inline choices. - for media itext with no translation, the value/form not output - probable bug: custom attributes not applied to repeat template (they appear in first repeat but not the jr:template).
- bump actions version numbers - update syntax for install, build, test
- either missing before, or mistakenly removed in commit f491ea8
46edd80
to
b7c496a
Compare
34866a8
to
64903fd
Compare
@lognaturel thanks for the review! I'll wait for #694 to be decided before merging. |
Let's go ahead and merge! I think we're going to let #694 simmer for a bit. We can always release off a special release branch if needed. |
Overall this PR modernises pyxform and lints a swathe of code. Most of the commits are progressive application of linter rules, which hopefully makes it clearer what is being done and why - refer to
pyproject.toml
to see what rules were enabled in that commit.Changes summary:
nose
1.3.7 (2015) to built-inunittest
, which can do everything required by pyxform. This also revealed some testing issues which are fixed:nose
was suppressing warnings so these were not visible until switching to unittest.nose
for some unknown reason.nose
for some unknown reason.flit
sincesetuptools
is no longer recommended for python. Another option ishatch
but it looked like it might be a bit overkill and/or introduce OS dependency requirements just for package building.ruff
, which has linter/formatter rules that encompass all the existing tools (black, flake8, isort) and many more. An initial batch of extra linting rule sets are enabled and applied.sphinx
baseddocs
stub folder - not published anywhere and broken anywayWhy is this the best possible solution? Were any other approaches considered?
These changes support upgrading pyxform supported Python versions, since the tools replaced in this PR are either out of date already or will not be supported in future.
A lot of code in pyxform is/was crufty due to it's origins in Python 2, and as a natural result of having dozens of committers over many years. The increased linting moves the code towards a more coherent style that is more consistent with modern Python code. This should make contributions easier in future.
What are the regression risks?
The update of AttributeColumnsTest seems to have revealed a bug introduced by #380 for custom attributes and repeats (will backref this ticket). Nobody seems to have complained about this though so perhaps it's a low priority to fix.
The release publishing GitHub action may not be 100% right since I'm not sure there's a nice way to test that.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
The code should be functionally equivalent for users. Where applicable, the
README
file has been updated.Before submitting this PR, please make sure you have:
tests
nosetests
unittest
and verified all tests passblack pyxform tests
ruff check pyxform tests
&ruff format pyxform tests
to lint and format code