Registry / testing / flake8-no-implicit-concat

flake8-no-implicit-concat

JSON →
library0.3.7pypypiunverified

flake8-no-implicit-concat is a Flake8 plugin designed to forbid implicit string and bytes literal concatenations in Python code. It helps enforce a coding style where string concatenation is always explicit, thereby preventing subtle bugs caused by accidentally concatenated literals. The current version is 0.3.7, and the project maintains an active release cadence with regular updates.

pip install flake8-no-implicit-concat
INSTALL
IMPORT
SIG · FLAKE8-NO-IMPLICIT
F
flake8-no-implicit-concat
testingpythonv0.3.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

After installation, `flake8-no-implicit-concat` is automatically registered with Flake8. Simply run `flake8` on your project to start detecting implicit string/bytes literal concatenations. The plugin uses error codes prefixed with 'NIC' (No Implicit Concatenation).

# Install the plugin pip install flake8-no-implicit-concat # Create a Python file with implicit concatenation (e.g., example.py) # print('hello' 'world') # Run flake8 to detect the issue flake8 example.py # Output will include a 'NIC' error, e.g.: # example.py:1:7: NIC001 Implicit string literal concatenation.
Debug
Known issues
gotchaImplicit string concatenation can lead to silent and hard-to-debug errors, especially when defining lists or tuples where a missing comma can result in two intended separate string elements becoming a single concatenated string. This plugin helps prevent such issues.
fix
Ensure all string concatenations are explicit (e.g., using `+` or `.join()`) or that separate string literals in collections are properly delimited by commas.
affects: All versions
gotchaBy default, `flake8-no-implicit-concat` only checks for implicit concatenations on the same line (NIC001). To also check for concatenations spanning multiple lines, you need to enable the `--check-str-concat-over-line-jumps=y` option.
fix
Add `--check-str-concat-over-line-jumps=y` to your Flake8 command or configuration file (e.g., `setup.cfg`, `pyproject.toml`) to enforce checking across line jumps.
affects: All versions
gotchaThis plugin specifically *forbids* implicit string concatenation. Be aware that another popular plugin, `flake8-implicit-str-concat`, has different goals and may *encourage* implicit concatenation in certain multi-line scenarios (e.g., within parentheses for PEP 8 compliance). Choose the plugin that aligns with your desired coding style.
fix
Review your project's coding style guide and select the appropriate plugin. If you want to strictly forbid all implicit concatenations, `flake8-no-implicit-concat` is the correct choice.
affects: All versions
Errors
Common errors & fixes
NIC001 Implicitly concatenated string literal
The `flake8-no-implicit-concat` plugin detected adjacent string or bytes literals that are implicitly concatenated, which the plugin forbids to promote explicit concatenation.
fix
Explicitly concatenate the string literals using the `+` operator, or separate them with a comma if they are elements in a collection. For example, change `'foo' 'bar'` to `'foo' + 'bar'` or `['foo', 'bar']`.
flake8-no-implicit-concat not working
The plugin might not be correctly installed within the same Python environment as Flake8, or Flake8 might not be configured to run the plugin.
fix
Ensure `flake8-no-implicit-concat` is installed in the same environment as Flake8 (e.g., `pip install flake8 flake8-no-implicit-concat`). If it's still not working, check your Flake8 configuration files (`.flake8`, `setup.cfg`, or `pyproject.toml`) to ensure no conflicting settings are present or that the plugin isn't explicitly disabled.
flake8 ignore NIC001
Users want to suppress the 'NIC001 Implicitly concatenated string literal' error for specific lines, files, or globally within their project.
fix
To ignore globally, add `ignore = NIC001` to your Flake8 configuration file (e.g., in `setup.cfg` under `[flake8]`). To ignore for a specific line, add `# noqa: NIC001` at the end of the line. To ignore for a specific file, add `# flake8: noqa` at the top of the file.
Upgrade
Version history
0.3.7latest on PyPI · released Nov 5, 2024
Audit
Dependencies
flake8requiredThis is a plugin for Flake8 and requires Flake8 to be installed to function.
Agent activity
6 hits · last 30 days
node
6
Resources
flake8-no-implicit-concat — pip install flake8-no-implicit-concat · libregistry