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

Error: Authors can be empty! #60

Open
Sogolumbo opened this issue Jul 15, 2022 · 3 comments
Open

Error: Authors can be empty! #60

Sogolumbo opened this issue Jul 15, 2022 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Sogolumbo
Copy link

Sogolumbo commented Jul 15, 2022

I get the following error:

[...]
File "...seo\seo_enhancer\html_enhancer\article_schema_creator.py", line 17, in __init__
    self._author = author.name
AttributeError: 'NoneType' object has no attribute 'name'

The reason for the error is:
The implicit assumption that the object author is not empty is wrong because there's the option to have no authors for an article.

@Sogolumbo
Copy link
Author

Proposed fix for this line:

    def __init__(self, author, title, category, date, logo, image, sitename):
        if author:
            self._author = author.name
        else:
            self._author=''
        self._title = title
        self._category = category.name
        self._publication_date = date
        self._logo = logo
        self._image = image
        self._sitename = sitename

@MaevaBrunelles
Copy link
Collaborator

Hi @Sogolumbo, thanks for raising this.

To fix this, I would go for this here:

        if self._author:
            schema_article["author"] = {"@type": "Person", "name": self._author.name}

Same issue for category.

Feel free to open a PR with according tests if you want to contribute :)

@MaevaBrunelles MaevaBrunelles added bug Something isn't working good first issue Good for newcomers labels Nov 12, 2022
@frica
Copy link

frica commented Mar 22, 2024

Hello,

Was it fixed? Doesn't look like it but maybe I'm wrong.
I use Pelican but I don't set Author because I'm the only one writing, and I'll be interested to look at this particular case.

Let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants