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

Variable only used in format string reported as "is not accessed" #7004

Open
CTimmerman opened this issue Mar 1, 2025 · 1 comment
Open
Assignees
Labels
needs repro Issue has not been reproduced yet waiting for user response Requires more information from user

Comments

@CTimmerman
Copy link

CTimmerman commented Mar 1, 2025

Environment data

  • Pylance version: 2025.2.1
  • OS and version: Windows 11 23H2
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.11

Code Snippet

escaped_command = "foo"
print(rf"\#0\f7> {escaped_command}")

Repro Steps

  1. Use Pylance and notice the faded variable and false report of variable not being accessed while it is via format string.

Expected behavior

Notice format string variable use.

Actual behavior

Image

XXX

Logs

XXX
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Mar 1, 2025
@debonte
Copy link
Contributor

debonte commented Mar 2, 2025

I'm unable to reproduce the issue with the code sample you provided. I believe we don't never flag module-level variables as unused, but even after moving the code inside a function I don't see escaped_command flagged as unused:

Image

If I comment out the print call, escaped_command is flagged as unused:

Image

Can you provide a more complete code sample that reproduces the issue?

@debonte debonte added the waiting for user response Requires more information from user label Mar 2, 2025
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 waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

3 participants