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

Advice (UFMT) command-failed Failed due to ASTSafetyError #4364

Closed
hippocookie opened this issue May 16, 2024 · 2 comments
Closed

Advice (UFMT) command-failed Failed due to ASTSafetyError #4364

hippocookie opened this issue May 16, 2024 · 2 comments
Labels
T: bug Something isn't working

Comments

@hippocookie
Copy link

Describe the bug

Running UFMT lint on PyTorch main branch code, and has following error message.

$ lintrunner -a --take UFMT test/quantization/**/*
Warning: Could not find a lintrunner config at: '.lintrunner.private.toml'. Continuing without using configuration file.
WARNING: The init commands have changed since you last ran lintrunner. You may need to run lintrunner init.

Lint for test/quantization/fx/test_quantize_fx.py:

Advice (UFMT) command-failed
Failed due to ASTSafetyError:
INTERNAL ERROR: Black produced code that is not equivalent to the source.
Please report a bug on https://github.com/psf/black/issues. This diff
might be helpful: /tmp/blk_d666mo2u.log

/tmp/blk_d666mo2u.log

  1 --- src
  2 +++ dst
  3 @@ -187103,11 +187103,11 @@
  4                      value=
  5                      Constant(
  6                          kind=
  7                          None,  # NoneType
  8                          value=
  9 -                        ' Test for function conv and functional conv + relu\n            ',  # str
 10 +                        'Test for function conv and functional conv + relu',  # str
 11                      )  # /Constant
 12                  )  # /Expr
 13                  Assign(
 14                      targets=
 15                      Name(

To Reproduce

Download source code from PyTorch github repo

git clone https://github.com/pytorch/pytorch.git

Remove below escape config in file .lintrunner.toml, in exclude_patterns of ufmt linter config section

'test/quantization/fx/test_quantize_fx.py',

Run lint command

lintrunner -a --take UFMT test/quantization/**/*

Expected behavior

Environment

Get versions info from conda

  • Black's version:
    Name Version Build Channel
    black 23.12.1 pypi_0 pypi

  • OS and Python version:
    Name Version Build Channel
    python 3.12.2 hab00c5b_0_cpython conda-forge

Additional context

@hippocookie hippocookie added the T: bug Something isn't working label May 16, 2024
@JelleZijlstra
Copy link
Collaborator

I believe we fixed this recently, could you try with the latest release?

If not, could you isolate the failure to a single file you can attach here?

@zsol
Copy link
Collaborator

zsol commented May 17, 2024

I bumped into this as well. Minimal repro is:

for i in _:
    """ foo"""

But it's been fixed in 24.4.0

@zsol zsol closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants