Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type checker aware of snakemake global in script files #32

Open
jlumpe opened this issue Dec 19, 2023 · 1 comment
Open

Make type checker aware of snakemake global in script files #32

jlumpe opened this issue Dec 19, 2023 · 1 comment

Comments

@jlumpe
Copy link

jlumpe commented Dec 19, 2023

Don't know how easy this is to do with an extension, but an annoyance of writing workflows in VS Code is the implicitly defined snakemake global variable. The type checker is not aware of this and will generate an "undefined variable" warning for each usage.

I'm using the following workaround for this:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from snakemake.script import Snakemake
    snakemake: Snakemake
    snakemake = None  # type: ignore

But it would be really great if this could be automatically applied somehow.

@Hugovdberg
Copy link

See snakemake/snakemake#2917, that will allow an explicit from snakemake.script import snakemake at runtime (so no if TYPE_CHECKING needed). I used a solution similar to yours for a while, but by implementing it in snakemake itself, it allows static analysis independent of the editor etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants