flake8-no-unnecessary-fstrings

raw JSON →
1.0.1 verified Fri May 01 auth: no python

A flake8 plugin that flags unnecessary f-strings (e.g., f"{var}" where a simple string or format would do). Current version: 1.0.1. Release cadence is low; no recent updates.

pip install flake8-no-unnecessary-fstrings
error flake8: F is not a recognized error code or it is being ignored
cause The plugin is not installed or flake8 cache is stale.
fix
Reinstall with 'pip install flake8-no-unnecessary-fstrings' and run 'flake8 --install-hook' or clear cache with 'flake8 --clear-cache'.
error flake8 no longer shows F error after upgrade
cause The rule code may conflict with other plugins or flake8's built-in rules.
fix
Explicitly enable the rule with '--select=F' in your flake8 configuration.
gotcha The plugin uses code 'F' for its rule, which conflicts with PyFlakes' F-coded rules. Ensure your flake8 configuration handles possible code collisions.
fix Use flake8's --select or --ignore with full code e.g., '--ignore=F' vs '--ignore=F401'.
gotcha Detects f-strings with no expressions as unnecessary, but also flags f-strings with only simple variable references (e.g., f"{var}"). This may be overly aggressive if you prefer f-strings for consistency.
fix Understand the rule's intent: ban f-strings that don't use f-string features (like formatting or multiple expressions). Consider disabling with --no-necessary-fstrings or adding noqa.

Install the plugin, configure flake8 to ignore rule F (if desired), then run flake8 on a file. The plugin adds rule code F.

echo -e '[flake8]\nextend-ignore = F' > .flake8 && flake8 your_file.py