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

Create Type Stub - entry is not showing up in quick fix options #6903

Open
judej opened this issue Jan 30, 2025 · 6 comments
Open

Create Type Stub - entry is not showing up in quick fix options #6903

judej opened this issue Jan 30, 2025 · 6 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@judej
Copy link
Contributor

judej commented Jan 30, 2025

Environment data

  • Pylance version: 2025.1.102 (pre-release)
  • OS and version: Windows 11, remote WSL Ubuntu 24.04
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.12

Repro Steps

Follow steps in testing/single/src/codeaction.py ln 89

Expected behavior

  • place cursor on event and confirm lightbulb shows up
  • and trigger quick fix and confirm Create Type Stub entry is listed
  • execute the code action and confirm it works as expected

Actual behavior

the Create Type Stub entry is not listed

Logs

2025-01-30 16:59:12.976 [info] [Trace - 4:59:12 PM] Sending request 'textDocument/hover - (20)'.
2025-01-30 16:59:12.977 [info] Params: {
    "textDocument": {
        "uri": "file:///root/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 15
    }
}


2025-01-30 16:59:12.981 [info] [Trace - 4:59:12 PM] Received response 'textDocument/hover - (20)' in 5ms.
2025-01-30 16:59:12.982 [info] No result returned.


2025-01-30 16:59:13.321 [info] [Trace - 4:59:13 PM] Sending request 'textDocument/hover - (21)'.
2025-01-30 16:59:13.321 [info] Params: {
    "textDocument": {
        "uri": "file:///root/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 14
    }
}


2025-01-30 16:59:13.322 [info] [Trace - 4:59:13 PM] Received response 'textDocument/hover - (21)' in 1ms.
2025-01-30 16:59:13.322 [info] No result returned.


2025-01-30 16:59:13.491 [info] [Trace - 4:59:13 PM] Sending request 'textDocument/codeAction - (22)'.
2025-01-30 16:59:13.492 [info] Params: {
    "textDocument": {
        "uri": "file:///root/pylance-release/testing/single/src/codeaction.py"
    },
    "range": {
        "start": {
            "line": 88,
            "character": 7
        },
        "end": {
            "line": 88,
            "character": 17
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                },
                "message": "Import \"zope.event\" could not be resolved",
                "code": "reportMissingImports",
                "codeDescription": {
                    "href": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingImports"
                },
                "severity": 1,
                "source": "Pylance"
            },
            {
                "range": {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                },
                "message": "\"zope.event\" is not accessed",
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "Pylance"
            }
        ],
        "only": [
            "quickfix"
        ],
        "triggerKind": 1
    }
}


2025-01-30 16:59:13.501 [info] [Trace - 4:59:13 PM] Received response 'textDocument/codeAction - (22)' in 10ms.
2025-01-30 16:59:13.501 [info] Result: [
    {
        "title": "Remove unused import",
        "command": {
            "title": "Remove unused import",
            "command": "python.removeUnusedImport",
            "arguments": [
                "file:///root/pylance-release/testing/single/src/codeaction.py",
                {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                }
            ]
        },
        "kind": "quickfix"
    },
    {
        "title": "Remove all unused imports",
        "command": {
            "title": "Remove all unused imports",
            "command": "python.removeUnusedImport",
            "arguments": [
                "file:///root/pylance-release/testing/single/src/codeaction.py"
            ]
        },
        "kind": "quickfix"
    },
    {
        "title": "Add '# type: ignore' to suppress warning",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///root/pylance-release/testing/single/src/codeaction.py": [
                    {
                        "range": {
                            "start": {
                                "line": 88,
                                "character": 17
                            },
                            "end": {
                                "line": 88,
                                "character": 17
                            }
                        },
                        "newText": " # type: ignore"
                    }
                ]
            }
        }
    },
    {
        "title": "Select a different interpreter",
        "command": {
            "title": "Select a different interpreter",
            "command": "python.setInterpreter"
        },
        "kind": "quickfix"
    },
    {
        "title": "Learn more about resolving imports",
        "command": {
            "title": "Learn more about resolving imports",
            "command": "pylance.openUri",
            "arguments": [
                [
                    "https://aka.ms/pylanceImportResolve"
                ]
            ]
        },
        "kind": "quickfix"
    }
]


2025-01-30 16:59:16.497 [info] [Trace - 4:59:16 PM] Sending request 'python/getConfigInfo - (23)'.
2025-01-30 16:59:16.497 [info] Params: [
    {
        "workspaceUri": "file:///root/pylance-release"
    },
    null
]


2025-01-30 16:59:16.499 [info] [Trace - 4:59:16 PM] Received response 'python/getConfigInfo - (23)' in 2ms.
2025-01-30 16:59:16.499 [info] Result: {
    "projectRoot": "file:///root/pylance-release",
    "typeCheckingMode": "basic"
}



@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jan 30, 2025
@rchiodo
Copy link
Contributor

rchiodo commented Jan 30, 2025

@judej Did you install the requirements first? This is expected if you didn't install the zope package.

@judej
Copy link
Contributor Author

judej commented Jan 31, 2025

yes, zope is installed.

Here are the logs at hover/quick fix event

2025-01-31 10:19:42.377 [info] [Trace - 10:19:42 AM] Sending request 'textDocument/hover - (456)'.
2025-01-31 10:19:42.377 [info] Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 13
    }
}
2025-01-31 10:19:42.378 [info] [Trace - 10:19:42 AM] Received response 'textDocument/hover - (456)' in 1ms.
2025-01-31 10:19:42.378 [info] No result returned.
2025-01-31 10:19:42.591 [info] [Trace - 10:19:42 AM] Sending request 'textDocument/hover - (457)'.
2025-01-31 10:19:42.591 [info] Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 12
    }
}
2025-01-31 10:19:42.592 [info] [Trace - 10:19:42 AM] Received response 'textDocument/hover - (457)' in 1ms.
2025-01-31 10:19:42.592 [info] No result returned.
2025-01-31 10:19:42.741 [info] [Trace - 10:19:42 AM] Sending request 'textDocument/codeAction - (458)'.
2025-01-31 10:19:42.742 [info] Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
    },
    "range": {
        "start": {
            "line": 88,
            "character": 7
        },
        "end": {
            "line": 88,
            "character": 17
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                },
                "message": "Import \"zope.event\" could not be resolved",
                "code": "reportMissingImports",
                "codeDescription": {
                    "href": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingImports"
                },
                "severity": 1,
                "source": "Pylance"
            },
            {
                "range": {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                },
                "message": "\"zope.event\" is not accessed",
                "severity": 4,
                "tags": [
                    1
                ],
                "source": "Pylance"
            }
        ],
        "only": [
            "quickfix"
        ],
        "triggerKind": 1
    }
}
2025-01-31 10:19:42.744 [info] [Trace - 10:19:42 AM] Received response 'textDocument/codeAction - (458)' in 3ms.
2025-01-31 10:19:42.744 [info] Result: [
    {
        "title": "Remove unused import",
        "command": {
            "title": "Remove unused import",
            "command": "python.removeUnusedImport",
            "arguments": [
                "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py",
                {
                    "start": {
                        "line": 88,
                        "character": 7
                    },
                    "end": {
                        "line": 88,
                        "character": 17
                    }
                }
            ]
        },
        "kind": "quickfix"
    },
    {
        "title": "Remove all unused imports",
        "command": {
            "title": "Remove all unused imports",
            "command": "python.removeUnusedImport",
            "arguments": [
                "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
            ]
        },
        "kind": "quickfix"
    },
    {
        "title": "Add '# type: ignore' to suppress warning",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py": [
                    {
                        "range": {
                            "start": {
                                "line": 88,
                                "character": 17
                            },
                            "end": {
                                "line": 88,
                                "character": 17
                            }
                        },
                        "newText": " # type: ignore"
                    }
                ]
            }
        }
    },
    {
        "title": "Select a different interpreter",
        "command": {
            "title": "Select a different interpreter",
            "command": "python.setInterpreter"
        },
        "kind": "quickfix"
    },
    {
        "title": "Learn more about resolving imports",
        "command": {
            "title": "Learn more about resolving imports",
            "command": "pylance.openUri",
            "arguments": [
                [
                    "https://aka.ms/pylanceImportResolve"
                ]
            ]
        },
        "kind": "quickfix"
    }
]
2025-01-31 10:19:44.516 [info] [Trace - 10:19:44 AM] Sending request 'textDocument/documentHighlight - (459)'.
2025-01-31 10:19:44.516 [info] Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 14
    }
}
2025-01-31 10:19:44.517 [info] [Trace - 10:19:44 AM] Received response 'textDocument/documentHighlight - (459)' in 1ms.
2025-01-31 10:19:44.518 [info] Result: [
    {
        "kind": 2,
        "range": {
            "start": {
                "line": 88,
                "character": 12
            },
            "end": {
                "line": 88,
                "character": 17
            }
        }
    }
]
2025-01-31 10:19:47.842 [info] [Trace - 10:19:47 AM] Sending request 'textDocument/documentHighlight - (460)'.
2025-01-31 10:19:47.842 [info] Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/user/source/microsoft/pylance-release/testing/single/src/codeaction.py"
    },
    "position": {
        "line": 88,
        "character": 14
    }
}
2025-01-31 10:19:47.843 [info] [Trace - 10:19:47 AM] Received response 'textDocument/documentHighlight - (460)' in 1ms.
2025-01-31 10:19:47.843 [info] Result: [
    {
        "kind": 2,
        "range": {
            "start": {
                "line": 88,
                "character": 12
            },
            "end": {
                "line": 88,
                "character": 17
            }
        }
    }
]

@rchiodo
Copy link
Contributor

rchiodo commented Jan 31, 2025

Are you sure you picked that interpreter? The import resolve error says it cannot find zope.event. That's not what I get.

Image

If there's an import resolve error that's why the create stub doesn't show up.

@judej
Copy link
Contributor Author

judej commented Feb 1, 2025

I did install zope.

Image

Image

Image

@rchiodo
Copy link
Contributor

rchiodo commented Feb 1, 2025

Perhaps the type stub is already there then?

@bschnurr
Copy link
Member

bschnurr commented Feb 4, 2025

need this setting.

"python.analysis.diagnosticSeverityOverrides": {
"reportMissingTypeStubs": "information"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants