Platform Specific Dependencies #10674
Unanswered
hmc-cs-mdrissi
asked this question in
Q&A
Replies: 1 comment
-
|
What I typically do in cases like this is to isolate the platform-specific behaviors into a single submodule within my code base. That way, the ugly (and somewhat fragile) conditional imports are relegated to a single place rather than scattered throughout my code. I don't know if that approach is feasible in your case, but I've found it greatly reduces the chances of a bug like this making it into production. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a codebase that is tested to run on both mac/linux. One of dependencies only works on linux and I try to do,
The ci I'm using has linux machines. Running ci job on mac is less convenient and would prefer not to require. Is there a good way to have pyright fail if I accidentally do import linux_dep outside a guarded area? I'm aware of pyright --pythonplatform=Darwin. That when run on linux machine with linux_dep installed won't fail though if it's imported outside guard.
I do have some control over linux_dep's codebase and could make changes to it if that'd help. Like I could add assert sys.platform == "linux" inside of it, but that would mostly just lead to a lot of code being unreachable and wouldn't error either.
edit: This question maybe fits better in typing discussion as while I expect answer will involve
--pythonplatformsomehow, rest of it is not pyright specific. I'll cross post it there.Beta Was this translation helpful? Give feedback.
All reactions