extend-immutable-calls: how to configure?
See original GitHub issueI haven’t been able to make the recently released feature extend-immutable-calls to work.
Have I configured it wrong?
I have verified that flake8 recognizes the config, by setting the line-length to 10 and verified flake8 warnings about line length.
flake8 --version
4.0.1 (flake8-bugbear: 21.11.29, mccabe: 0.6.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.10.0 on
Darwin
example.py
import fastapi
def example_fn(data: str = fastapi.Header(None)):
pass
setup.cfg
[flake8]
max-line-length = 120
extend-immutable-calls = ["fastapi.Header"]
flake8 --show-source
./example.py:4:28: B008 Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.
def example_fn(data: str = fastapi.Header(None)):
^
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to extend immutable types in Java - Stack Overflow
In Java immutable classes are usually marked final and cannot be extended. See String as an example. That rules out option number 2....
Read more >Immutable Classes in Java - HowToDoInJava
Learn about immutable objects, records and collections in Java and create a Java class immutable step by step ... Final classes in Java...
Read more >How to create an immutable class with mutable object ...
To create a custom immutable class we have to do the following steps. Declare the class as final so it can't be extended....
Read more >Simple Steps to Create Immutable Class in Java - DZone
In order to create an immutable class, you should follow the below steps: Make your class final, so that no other classes can...
Read more >Complete Guide to the Immutables Java Library - Reflectoring
All attributes in the immutable class are mandatory by default. If we want to create a field where we can omit the value,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You want:
Same problem here - I tried to silence
pathlib.Path.