You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suggest to purge this hack from network.py; the RTD config already installs canopen as a package, which implicitly installs can. Moreover, purging this workaround will make it easier to add type annotations for network.py.
Yes, please. With type annotation checks we'd need code something like this to circumvent the conditional:
fromtypingimportTYPE_CHECKINGtry:
importcanfromcanimportListenerfromcanimportCanErrorexceptImportError:
# Type checkers don't like this conditional logic, so it is only run when# not type checkingifnotTYPE_CHECKING:
# Do not fail if python-can is not installedcan=NoneCanError=ExceptionclassListener:
""" Dummy listener """
When these workarounds were added, there was no doc/requirements.txt, no .readthedocs.yaml. Not having python-can installed would render the library totally useless at any of these three points in time; hence, the changes were made because of other reasons, and d2748f9 is explicit about it: fix the RTD build.
Could it have merit for other use cases?
No; the code is completely broken if the imports fail; python-can is a hard dependency for canopen. This goes for the state of the code base for all three referenced commits.
Ah, thanks for the explanation @erlend-aasland. That's what I wanted to know, and especially it seems there was no special funky use-case that required this.
Activity
Purge import hack from network.py
friederschueler commentedon Jul 9, 2024
Yes, I think this is a good change.
sveinse commentedon Jul 10, 2024
Yes, please. With type annotation checks we'd need code something like this to circumvent the conditional:
Purge import hack from network.py (canopen-python#510)
acolomb commentedon Jul 10, 2024
I'd like to go back to the basics of this issue. How exactly is this related to the documentation build?
Could it have merit for other use cases?
Sorry, I just haven't fully grasped what this passage is meant to do in the first place.
erlend-aasland commentedon Jul 10, 2024
The except clause was historically added and changed with these commits (new to old):
When these workarounds were added, there was no
doc/requirements.txt, no.readthedocs.yaml. Not havingpython-caninstalled would render the library totally useless at any of these three points in time; hence, the changes were made because of other reasons, and d2748f9 is explicit about it: fix the RTD build.No; the code is completely broken if the imports fail;
python-canis a hard dependency forcanopen. This goes for the state of the code base for all three referenced commits.acolomb commentedon Aug 6, 2024
Ah, thanks for the explanation @erlend-aasland. That's what I wanted to know, and especially it seems there was no special funky use-case that required this.
erlend-aasland commentedon Aug 6, 2024
No sweat, it's always good to be reminded about Chesterton's Fence :)