plugin-python icon indicating copy to clipboard operation
plugin-python copied to clipboard

How to use it with prettier API?

Open shreyas-a opened this issue 7 years ago • 1 comments

When I try to use it with following configuration, it throws

TypeError: Cannot read property 'toString' of null

prettier.format("print('Hello, world!')", {
  parser: 'python',
  plugins: ['@prettier/plugin-python'],
});

shreyas-a avatar Jul 05 '18 09:07 shreyas-a

I can't reproduce this error:

azz at macOS in ~/code/tmp on master [+!?]
$ cat format.js 
let prettier = require('prettier')

let result = prettier.format("print('Hello, world!')", {
  plugins: ['@prettier/plugin-python'],
  parser: 'python'
})

console.log(result)
azz at macOS in ~/code/tmp on master [+!?]
$ node format.js 
print("Hello, world!")


azz at macOS in ~/code/tmp on master [+!?]
$ yarn list prettier
yarn list v1.3.2
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ @prettier/[email protected]
│  └─ [email protected]
└─ [email protected]

azz avatar Jul 29 '18 05:07 azz