question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extend-immutable-calls: how to configure?

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sco1commented, Feb 1, 2022

You want:

[flake8]
max-line-length = 120
extend-immutable-calls = fastapi.Header
1reaction
aberrescommented, Jan 17, 2022

Same problem here - I tried to silence pathlib.Path.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found