wemake-services / flake8-broken-line Goto Github PK
View Code? Open in Web Editor NEWπ¨ Flake8 plugin to forbid backslashes (\) for line breaks
Home Page: https://pypi.org/project/flake8-broken-line/
License: MIT License
π¨ Flake8 plugin to forbid backslashes (\) for line breaks
Home Page: https://pypi.org/project/flake8-broken-line/
License: MIT License
Thank you for your great strict linting job! I have an IRL question, and maybe it's a good idea to add more examples to README.
For example I have long chain of methods without arguments:
some_object \
.call_method() \
.call_other() \
.finalize()
So it should be:
some_objects.call_method(
).call_other(
).finalize()
or
some_objects.call_method(
).call_other(
).finalize()
?
"SolverProblemError
Because flake8-broken-line (0.6.0) depends on flake8 (>=3.5,<6) and no versions of flake8-broken-line match >0.6.0,<0.7.0, flake8-broken-line (>=0.6.0,<0.7.0) requires flake8 (>=3.5,<6). So, because project depends on both flake8 (^6.0.0) and flake8-broken-line (^0.6.0), version solving failed."
If I have a long import then how should I short it?
I have this:
from app.baz.bar.foo.first_word.second_word.handler import post as first_word_second_word_scoring
And it is longer than 100 symbols in one line. Isort does the following for me:
from app.baz.bar.foo.first_word.second_word.handler import \
post as first_word_second_word_scoring
And I got: N400: Found backslash that is used for line breaking
Minimal code to reproduce:
"""
\
"""
Currently, there are errors in our CI: https://travis-ci.com/github/sobolevn/flake8-broken-line/jobs/334338507
It needs to be fixed. Probably it would be safe to say that poetry update
will do the thing.
And it is also required to update lots of deps from @dependabot-bot updates that are not mergable at the moment.
List: https://github.com/sobolevn/flake8-broken-line/pulls
Dependabot can't resolve your Python dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Creating virtualenv flake8-broken-line-TAFSsRl8-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...
[PackageNotFound]
Package pytest-isort (0.3.1) not found.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
Hi,
Trying to update flake8 to 4.x is not possible because this extension forces it to be <4.0. Probably there isn't any broken changes, but the dependency needs to be loosen
This works as expected:
an_r_string = r'''
Hello \
World
'''
But this raises an error:
planet = 'Earth'
an_r_string = fr'''
Hello \
{planet}
'''
A recent change made this plugin work with flake8 version 5, but this is still unreleased and actively blocking from migrating to the new flake8 version.
Dependabot can't resolve your Python dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Creating virtualenv flake8-broken-line-M5gsrVWi-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...
[PackageNotFound]
Package pytest-isort (0.3.1) not found.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
Dependabot can't resolve your Python dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Creating virtualenv flake8-broken-line-KHe-WgIB-py3.8 in /home/dependabot/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies...
[PackageNotFound]
Package pytest-isort (0.3.1) not found.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
The first two examples are good because they provide reasonable alternatives to using the line break. But the third, I'm not sure what it means. How is the programming "implementing" chaining? Can we just suggest a Pythonic alternative instead?
If i have:
text = """
...
very long line 1 - very long line 2
...
"""
So i have E501 (line to long). This is not so beautiful, so i change:
text = """
...
very long line 1 - \
very long line 2
...
"""
And now i have N400 (Found backslash that is used for line braking)
What should i do on this?
flake8 --version
3.8.2 (flake8-broken-line: 0.2.0, flake8-bugbear: 20.1.4, flake8-colors:
0.1.0, flake8-comprehensions: 3.2.2, flake8-eradicate: 0.3.0, flake8_commas:
2.0.0, flake8_isort: 3.0.0, mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes:
2.2.0) CPython 3.6.3 on Linux
code to repro
'''\
'''
The \
there is used to elminate the newline from the literal string block as noted 1/2 page down or so here (https://docs.python.org/3.6/tutorial/introduction.html#strings)
String literals can span multiple lines. One way is using triple-quotes: """...""" or '''...'''. End of lines are automatically included in the string, but itβs possible to prevent this by adding a \ at the end of the line. The following example:
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
Given this example, explicitly allowed by PEP8 (lit. Backslashes may still be appropriate at times. For example, long, multiple with-statements cannot use implicit continuation, so backslashes are acceptable
):
async def fnc():
async with asdf() as a, \
bsdf():
return 1
with asdf() as a, \
bsdf():
return 1
with \
asdf() as a, \
bsdf():
return 1
This plugin gives many non-PEP8-compliant false positives:
test_continuation.py:2:1: N400: Found backslash that is used for line breaking
async with asdf() as a, \
bsdf():
^
test_continuation.py:6:1: N400: Found backslash that is used for line breaking
with asdf() as a, \
bsdf():
^
test_continuation.py:11:1: N400: Found backslash that is used for line breaking
with \
asdf() as a, \
bsdf():
^
test_continuation.py:12:3: N400: Found backslash that is used for line breaking
with \
asdf() as a, \
bsdf():
^
A backslash at the end of a comment is detected as a line-breaking slash.
# A remote path can be entered. e.g.: \\server\
N400: Found backslash that is used for line braking
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.