import version1
import version2
try:
version2.load_data(input)
except ValidationError:
version1.load_data(input)
I'm sure people will abuse it, but the idea doesn't seem terrible on the face of it to me. import version1
import version2
try:
version2.load_data(input)
except ValidationError:
version1.load_data(input)
I'm sure people will abuse it, but the idea doesn't seem terrible on the face of it to me. import version2
try:
version2.load_data(input)
except ValidationError:
import version1
version1.load_data(input)
(Assuming version in name like this example version2 or lib2 etc.)With a tool like rope, I feel fairly confident I can refactor a source available, pure python dependency, pretty quickly.
Where I get less comfortable with my idea is that not every dependency has source available (e.g. db2 database driver as an example).
Another case is where some deps which have source available but the python module dependency is in C/C++/Rust - e.g. scipy
Of course, you can change the import name between versions. That's one of the upsides of not tying the import name to the distribution name, and many real-world projects actually do this as part of a deprecation cycle (for example, `imageio` has been doing it with recent versions, offering "v2" and "v3" APIs). But in the general case, you'd have to change it with every version (since your transitive dependencies might want different minor/patch versions for some obscure reason - semver is only an ideal, after all), which in turn means your users would always have to pin their dependency to the exact version described by the code.