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

Regression in 2023.10.41 quick-fix pyright-specific comments #5565

Closed
garthk opened this issue Mar 2, 2024 · 2 comments
Closed

Regression in 2023.10.41 quick-fix pyright-specific comments #5565

garthk opened this issue Mar 2, 2024 · 2 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@garthk
Copy link

garthk commented Mar 2, 2024

#4494 is not as fixed as its status would suggest. Perhaps it lacks test coverage and regressed between then and 2024.2.105, but I suspect it didn't work (well) then either and wasn't picked back up despite a timely warning from the original reporter #4494 (comment).

The fix was announced in 2023.10.41 (20 October 2023) PreRelease:

Notable changes:

Yeah, nah, I'm afraid not. See this fresh profile fail to use the feature (3 frames, 5s each):

animation

Environment data

  • Python extension v2024.3.10611008 (pre-release)
  • Pylance extension v2024.2.105 (pre-release)
  • Pylance language server: 2024.2.105 (pyright version 1.1.351, commit 87171fbf)
  • OS and version: macOS 14.3.1 (23D60)
  • Python version: 3.11.8
  • … and distribution if applicable: brew install python3

Code Snippet

class Assignment:
	content_object: Any | None

	def get_absolute_url(self) -> str:
		"""Get the canonical URL for this assignment."""
		model: Model = self.content_object
		return resolve_url(to=model)


class Model:
	def get_absolute_url(self) -> str:
		return 'https://github.com/microsoft/pylance-release/issues/4494'


def resolve_url(to: Model) -> str:
	return ''

Repro Steps

  • Move cursor into self.content_object
  • Use editor.action.showHover (⌘K ⌘I by default on macOS)
  • Use editor.action.quickFix (⌘.)
  • Observe you didn't get an error-specific suppression
  • Observe you didn't get a Pyright-specific suppression

For more detail and an importable profile so you know our settings match, clone garthk/0847190… (gist).

Expected behavior

I expect this quick fix to be offered, and a matching comment added:

Add '# pyright: ignore[reportAssignmentType]' to suppress warning

Actual behavior

Add '# type: ignore' to suppress warning

Logs

See python-analysis.log in the gist.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Mar 2, 2024
@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Mar 2, 2024
@debonte
Copy link
Contributor

debonte commented Mar 2, 2024

If you add the following to your pyproject.toml, you will see the # pyright: ignore[foo] code action. We currently show either # type: ignore or # pyright: ignore depending on the value of the enableTypeIgnoreComments setting.

[tool.pyright]
enableTypeIgnoreComments = false

However, there is a problem. When reportGeneralTypeIssues got split into multiple smaller diagostic rules, this code action wasn't updated to use the rule name, so the comment is always # pyright: ignore[reportGeneralTypeIssues] which is obviously problematic.

I'll work on a fix for that.

@debonte debonte added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Mar 7, 2024
@StellaHuang95
Copy link
Contributor

This issue has been fixed in prerelease version 2024.3.100, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants