-
Notifications
You must be signed in to change notification settings - Fork 22
Improve user agent handling in login classes #925
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -223,7 +223,7 @@ def __init__(self, user: Optional[str] = None, password: Optional[str] = None, m | |||||
| } | ||||||
|
|
||||||
| headers = { | ||||||
| 'User-Agent': get_user_agent(user_agent) | ||||||
| 'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None)) | ||||||
| } | ||||||
|
|
||||||
| allowed_kwargs = {'headers', 'proxies', 'timeout', 'verify'} | ||||||
|
|
@@ -282,7 +282,7 @@ def __init__(self, user: Optional[str] = None, password: Optional[str] = None, m | |||||
| } | ||||||
|
|
||||||
| headers = { | ||||||
| 'User-Agent': get_user_agent(user_agent) | ||||||
| 'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None)) | ||||||
|
||||||
| 'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None)) | |
| 'User-Agent': get_user_agent(user_agent) |
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.
The fallback logic
user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None)is redundant here. The variableuser_agentwas already resolved with the same fallback logic on line 215, so this line can be simplified to justget_user_agent(user_agent).