Skip to content

Check if variable is already a bool before converting it#3232

Closed
tshirtman wants to merge 1 commit into
psf:mainfrom
tshirtman:master
Closed

Check if variable is already a bool before converting it#3232
tshirtman wants to merge 1 commit into
psf:mainfrom
tshirtman:master

Conversation

@tshirtman
Copy link
Copy Markdown

Description

I had issue running Black in vim after recent updates (notably using vim > 9, linked against python 3.10.4), getting error:

TypeError: bool object expected; got int

after some tinkering i found that the values defined (or not) in pyproject.toml were the culprit. But even adding

string_normalization = false                                    
fast = true
quiet = false

in the black block of pyproject.toml, didn't help, as it was trying to convert a bool to a bool, as if it was a string,

AttributeError: 'bool' object has no attribute 'lower'

but even adding quotes around the values still got me the original "bool object expected; got int", error.

So i replaced the usage of strtobool with something more robust, using ConfigParser.BOOLEAN_STATES.get and falling back on False.

Checklist - did you ...

  • Add a CHANGELOG entry if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Not sure any of these are necessary, for the vim plugin.

@tshirtman
Copy link
Copy Markdown
Author

tshirtman commented Aug 19, 2022

Hm, seems i was not up to date, closing and reassessing.

edit: yep, works now, i guess vim-plug didn't update because it still though the master branch was the latest version, switched to main now.

@tshirtman tshirtman closed this Aug 19, 2022
@ichard26
Copy link
Copy Markdown
Collaborator

No worries, glad you could sort out your issue in the end! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants