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

Unexpected exception: int object expected; got str #59

Closed
eggplants opened this issue May 14, 2022 · 5 comments · Fixed by #60
Closed

Unexpected exception: int object expected; got str #59

eggplants opened this issue May 14, 2022 · 5 comments · Fixed by #60

Comments

@eggplants
Copy link
Contributor

eggplants commented May 14, 2022

ref: #47, RDFLib/rdflib#1927 (comment)

when I use flake8-black in rdflib, rdflib/***.py:0:1: BLK999 Unexpected exception: int object expected; got str is raised 89 times.

$ flake8 --version
4.0.1 (black: 0.3.2, mccabe: 0.6.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.9.10 on Linux
$ git clone https://github.com/RDFLib/rdflib && cd rdflib
...
$ flake8 rdflib | grep "BLK999 Unexpected exception" | wc -l
89
aucampia added a commit to aucampia/rdflib that referenced this issue May 14, 2022
This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
aucampia added a commit to aucampia/rdflib that referenced this issue May 14, 2022
This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- `flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
- Remove redundant/duplicated config for flake8
aucampia added a commit to aucampia/rdflib that referenced this issue May 14, 2022
This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- `flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
- Remove redundant/duplicated config for flake8
aucampia added a commit to aucampia/rdflib that referenced this issue May 14, 2022
This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- `flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
- Remove redundant/duplicated config for flake8
@peterjc
Copy link
Owner

peterjc commented May 14, 2022

Ah yes, you raised this on #47 but we never managed to reproduce this.

Can you confirm which version of black you have installed?

@eggplants
Copy link
Contributor Author

eggplants commented May 14, 2022

$ black --version
black, 22.3.0 (compiled: yes)

This problem confirmed to happen in not only my environment but also other people's ones...

@peterjc
Copy link
Owner

peterjc commented May 14, 2022

Good news - I can reproduce that on macOS with Python 3.8, so not OS nor Python version specific:

$ flake8 --version
4.0.1 (black: 0.3.2, mccabe: 0.6.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.8.5 on Darwin

Disabling my error catching,

...
  File "/Users/xxx/repositories/flake8-black/flake8_black.py", line 212, in run
    file_mode = self._file_mode
  File "/Users/xxx/repositories/flake8-black/flake8_black.py", line 123, in _file_mode
    black_config[path] = load_black_mode(path)
  File "/Users/xxx/repositories/flake8-black/flake8_black.py", line 69, in load_black_mode
    return black.FileMode(
  File "<string>", line 4, in __init__
TypeError: int object expected; got str

I'll get back to this later - but am optimistic about fixing this now. Thanks!

aucampia added a commit to aucampia/rdflib that referenced this issue May 15, 2022
This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- `flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
- Remove redundant/duplicated config for flake8
aucampia added a commit to RDFLib/rdflib that referenced this issue May 15, 2022
* Enable and baseline flakeheaven

This patch adds flakeheaven with a baseline, the baseline ignores all
existing errors and only reports on new errors.

The benefit with this approach is that we can get full flake8 on new
changes without having to first address the flake8 warnings with our
existing codebase.

Baselined errors can still be seen with:
- `flakeheaven lint --baseline /dev/null`
- `flake8`

This also adds a flakeheaven to GitHub Actions in a way which will
result in independent reporting.

Other changes:
- Simplified caching behaviour in GitHub Actions
- Removed flake8-black because it does not work well

  peterjc/flake8-black#59
- Remove redundant/duplicated config for flake8

Co-authored-by: Christian Clauss <cclauss@me.com>
@peterjc
Copy link
Owner

peterjc commented May 16, 2022

Also breaks with black 22.1.0, and I have a work around for you:

$ git diff
diff --git a/pyproject.toml b/pyproject.toml
index efe383b0..a672bdd7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.black]
 required-version = "22.3.0"
-line-length = "88"
+line-length = 88
 skip-string-normalization = true
 target-version = ['py37']
 include = '\.pyi?$'

It looks like your TOML has line-length defined as a string, which I am passing to black as is when black wants and integer.

@peterjc
Copy link
Owner

peterjc commented May 16, 2022

Release v0.3.3 should fix this. Thank you for the reproducible example, incredibly helpful.

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 a pull request may close this issue.

2 participants