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

Improve code quality #76

Merged
merged 3 commits into from
Dec 24, 2021
Merged

Improve code quality #76

merged 3 commits into from
Dec 24, 2021

Conversation

michadenheijer
Copy link
Owner

A lot of code was all in one file, this seems much cleaner. Also add some more documentation.

raise TypeError("Max results needs to be int")


def tag_query_get_filter_options(filter_options) -> Optional[str]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tag_query_get_filter_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

import re


def parse_date(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parse_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

pynytimes/api.py Outdated
"""Creates the New York Times API class.

Args:
key (str, optional): Your key to access the NYT developer API. Get your key at https://developer.nytimes.nl. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (138 > 79 characters)


Args:
key (str, optional): Your key to access the NYT developer API. Get your key at https://developer.nytimes.nl. Defaults to None.
https (bool, optional): Optionally disable HTTPS, not advised. Defaults to True.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (92 > 79 characters)

Args:
key (str, optional): Your key to access the NYT developer API. Get your key at https://developer.nytimes.nl. Defaults to None.
https (bool, optional): Optionally disable HTTPS, not advised. Defaults to True.
session (Session, optional): Use your own Session object. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (87 > 79 characters)

pynytimes/api.py Outdated
"""Get most shared articles

Args:
days (Literal[1, 7, 30], optional): Period of the most shared articles. Defaults to 1.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (98 > 79 characters)

pynytimes/api.py Outdated

Args:
days (Literal[1, 7, 30], optional): Period of the most shared articles. Defaults to 1.
method (Literal["email, "facebook"], optional): Choose the source of shared articles. Defaults to "email".
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (118 > 79 characters)


Args:
author (Optional[str], optional): Name of author. Defaults to None.
isbn (Union[str, int, None], optional): ISBN of book. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (83 > 79 characters)

pynytimes/api.py Outdated
"""Load all the best seller lists"""
# Set URL, load and return data
url = BASE_BEST_SELLERS_LISTS
"""Get all the best sellers lists (not the contents of these lists, but just all the lists).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (92 > 79 characters)

pynytimes/api.py Outdated
if date is None:
_date = "current"
Args:
date (Union[datetime.date, datetime.datetime, None], optional): The list closest to this date. If left empty loads most recent. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (157 > 79 characters)

backoff (bool, optional): Optionally disable the automatic backoff,
this is only advised if you implement your own. Defaults to True.
user_agent (str, optional): Set your own user-agent. Defaults to None.
parse_dates (bool, optional): Optionally parse all dates into datetime objects.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (91 > 79 characters)

"""Get most shared articles

Args:
days (Literal[1, 7, 30], optional): Period of the most shared articles.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (83 > 79 characters)

_date = "current"
Args:
date (Union[datetime.date, datetime.datetime, None], optional):
The list closest to this date. If left empty loads most recent. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (93 > 79 characters)

Args:
date (Union[datetime.date, datetime.datetime, None], optional):
The list closest to this date. If left empty loads most recent. Defaults to None.
name (str, optional): Name of the list. Defaults to "combined-print-and-e-book-fiction".
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (100 > 79 characters)

options (Optional[dict[str, Any]], optional): Options object
where certain requirements can be set. Check for more
https://github.com/michadenheijer/pynytimes. Defaults to None.
dates (Optional[ dict[str, Union[datetime.date, datetime.datetime]] ], optional):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (93 > 79 characters)

if not isinstance(section, str):
raise TypeError("Section needs to be str")
Args:
source (Literal["all", "nyt", "inyt"], optional): Select sources to get all
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (87 > 79 characters)


Args:
query (str): Search query to find a tag
filter_option (Optional[dict[str, Any]], optional): Filter the tags.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (80 > 79 characters)


Args:
query (Optional[str], optional): Search query. Defaults to None.
dates (Optional[ dict[str, Union[datetime.date, datetime.datetime, None]] ], optional):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (99 > 79 characters)

query (Optional[str], optional): Search query. Defaults to None.
dates (Optional[ dict[str, Union[datetime.date, datetime.datetime, None]] ], optional):
Values between which results should be. Defaults to None.
options (Optional[dict[str, Any]], optional): Options for the search results.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (89 > 79 characters)

Values between which results should be. Defaults to None.
options (Optional[dict[str, Any]], optional): Options for the search results.
Defaults to None.
results (int, optional): Load at most this many articles. Defaults to 10.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line too long (85 > 79 characters)

@michadenheijer michadenheijer merged commit 46c995b into main Dec 24, 2021
@michadenheijer michadenheijer deleted the code-quality-improvements branch December 24, 2021 19:30
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

Successfully merging this pull request may close these issues.

1 participant