Removing the need for unit tests to access protected attributes without adding to the public API (Reader()._offsets)
JamesParrott opened this issue · 0 comments
JamesParrott commented
PyShp Version
2.4.3
Python Version
3
Your code
pylint --disable=R,C test_shapefile.pyFull stacktrace
pylint --disable=R,C test_shapefile.py
************* Module test_shapefile
test_shapefile.py:784:19: W0212: Access to a protected member _offsets of a client class (protected-access)
test_shapefile.py:787:19: W0212: Access to a protected member _offsets of a client class (protected-access)
test_shapefile.py:800:19: W0212: Access to a protected member _offsets of a client class (protected-access)
test_shapefile.py:804:19: W0212: Access to a protected member _offsets of a client class (protected-access)
test_shapefile.py:807:19: W0212: Access to a protected member _offsets of a client class (protected-access)
test_shapefile.py:1196:19: W0212: Access to a protected member _offsets of a client class (protected-access)
------------------------------------------------------------------
Your code has been rated at 9.90/10 (previous run: 8.82/10, +1.08)Other notes
PyShp's unit tests test implementation details, querying Reader()._offsets.
Pylint, an opinionated tool, thinks this is bad.
One dev thinks this "means that a private class is hiding inside your code waiting to be created" https://stackoverflow.com/a/71726947/20785734
If anyone can think how to create such a private class for ._offsets (so closely coupled with Reader), and rewrite the corresponding tests to use public methods on such a class, with a minimum number of changes, without changing either the functionality being tested or the tests, such that W0212 is passed, then please comment below and I will reopen this issue.