Skip to content

Content of f-string interpreted as commented code #266

@krzysztof3-wisniewski

Description

@krzysztof3-wisniewski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions