-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
raise TypeError("Max results needs to be int") | ||
|
||
|
||
def tag_query_get_filter_options(filter_options) -> Optional[str]: |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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". |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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". |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)
A lot of code was all in one file, this seems much cleaner. Also add some more documentation.