Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content of f-string interpreted as commented code #266

Open
krzysztof3-wisniewski opened this issue Aug 29, 2022 · 0 comments
Open

Content of f-string interpreted as commented code #266

krzysztof3-wisniewski opened this issue Aug 29, 2022 · 0 comments

Comments

@krzysztof3-wisniewski
Copy link

krzysztof3-wisniewski commented Aug 29, 2022

Using flake8-eradicate==1.2.1
On CPython 3.9.13
With flake8==4.0.1
Using the following code as an example

class FooClass(SpamClass):
    def render_html(self) -> str:
        return f"""
        <div>
            <div>
                <h2>
                    spam content <bold>{self.foo.bar().car()}</bold> to <bold>foo</bold><br/>
                </h2>
                <i>
                    “Some quote.”
                    <br/>~Quote author
                <i/>
            <div>
            </div>
                <table>
                    <tbody>
                        <tr>
                            <td><bold>Foo foo</bold></td>
                            <td>{self.bar.foo}</td>
                        </tr>
                        <tr>
                            <td><bold>Bar foo</bold></td>
                            <td>{self.barbar.foo}</td>
                        </tr>
                        <tr>
                            <td><bold>Foo spam</bold></td>
                            <td>
                                <a href="https://service.com/spam/foo/bar/{self.foo.car}">
                                    #{self.foo.car}
                                <a/>
                            </td>
                        </tr>
                        <tr>
                            <td><bold>Spam bar</bold></td>
                            <td>{self.foo()}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        """

Following snipped, line #{self.foo.car} generates an error Found commented out code flake8(E800)

<a href="https://service.com/spam/foo/bar/{self.foo.car}">
    #{self.foo.car}
<a/>

Which, of course, is not correct because we are not dealing with a comment here. Removing the # from the content makes the error disappear, however, this is not the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant