gijzelaerr / python-snap7

A Python wrapper for the snap7 PLC communication library
http://python-snap7.readthedocs.org/
MIT License
643 stars 246 forks source link

Make all internal imports relative #386

Closed vmsh0 closed 1 year ago

vmsh0 commented 2 years ago

Not sure whether this is welcome, but we're using is as an internal patch and I thought it would be nice to offer it here.

This basically allows more freedom installing and moving the snap7 module around the filesystem for peculiar setups, as far as I know it's a pretty common practice for Python libraries.

vmsh0 commented 2 years ago

Not sure why some tests are failing, is it due to my changes? Will check more later.

swamper123 commented 2 years ago

Relative imports can be handy, as long as you know what you do. I made the experience, that in more nested projects, many people fall into an ImportError pit (but that is another story).

Anyway - back to the topic: In our case I am not so happy, because of types. types is a buitin module itself, but also a module in our repo. If we want to use relative imports, a refactoring has to happen to differ both things better for readability (and maybe future conflicts) reasons. Other opinions are welcomed :)

vmsh0 commented 2 years ago

Anyway - back to the topic: In our case I am not so happy, because of types. types is a buitin module itself, but also a module in our repo. If we want to use relative imports, a refactoring has to happen to differ both things better for readability (and maybe future conflicts) reasons. Other opinions are welcomed :)

Very good point, but as long as the built-in types is not used in the project I don't see it as a terrible thing. (at least compared to what it is already)

vmsh0 commented 1 year ago

I've changed all the types imports to drop the prefix and just explicitly import the names.