-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sourcery refactored main branch #1
base: main
Are you sure you want to change the base?
Conversation
if not all(field in data for field in expected_data): | ||
if any(field not in data for field in expected_data): | ||
return False, 'Invalid data format' | ||
|
||
if data['Employment Type'] not in allowed_employment_types: | ||
return False, 'Invalid Employment Type' | ||
|
||
if data['Experience Level'] not in allowed_experience_levels: | ||
return False, 'Invalid Experience Level' | ||
|
||
#TODO: Add more checks like insurance it's within users country!!! | ||
|
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 validate_job_data
refactored with the following changes:
- Invert any/all to simplify comparisons (
invert-any-all
)
|
||
# Create a signature | ||
signature = private_key.sign( | ||
|
||
return private_key.sign( | ||
data, | ||
padding.PSS( | ||
mgf=padding.MGF1(hashes.SHA256()), | ||
salt_length=padding.PSS.MAX_LENGTH | ||
salt_length=padding.PSS.MAX_LENGTH, | ||
), | ||
hashes.SHA256() | ||
) | ||
|
||
# return signature.hex() #used this when I didn't have any default_backend code!!! | ||
return signature No newline at end of file | ||
hashes.SHA256(), | ||
) |
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 sign_data
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# return signature.hex() #used this when I didn't have any default_backend code!!!
# Create a signature
|
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 CompanyWorkflow.company_workflow
refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
This removes the following comments ( why? ):
# NEW NEW NEW NEW
#! FAILS: If "Internal-Job-Listings" is the initial webpage this ruins
#TODO: refactor this!
language_of_webpage = predictions[0][0].replace('__label__', '') | ||
#TODO: Determine whether this should go here or somewhere else!! | ||
# if language_of_webpage == 'en': | ||
# return True | ||
# else: | ||
# return False | ||
# = = = = | ||
# return language_of_webpage == 'en' | ||
return language_of_webpage | ||
return predictions[0][0].replace('__label__', '') |
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 CompanyWorkflow.check_language_of_webpage
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# if language_of_webpage == 'en':
# = = = =
# return False
#TODO: Determine whether this should go here or somewhere else!!
# return True
# return language_of_webpage == 'en'
# else:
elements = { | ||
|
||
return { |
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 CompanyWorkflow.url_parser
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if arg == 'greenhouse': | ||
if arg in ['greenhouse', 'lever']: | ||
print(method_name) | ||
print(arg) | ||
for key, value in kwargs.items(): | ||
print(key + ": " + str(value)) | ||
elif arg == 'lever': | ||
print(method_name) | ||
print(arg) | ||
for key, value in kwargs.items(): | ||
print(key + ": " + str(value)) | ||
print(f"{key}: {str(value)}") |
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 CompanyWorkflow.print_companies_internal_job_opening
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
if re.search(experience_needed, everything_about_job): | ||
return False | ||
else: | ||
return True | ||
return not re.search(experience_needed, everything_about_job) |
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 CompanyWorkflow.should_user_apply
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
|
||
if input_element.get('type') == 'radio': | ||
label = self.find_radio_label(input_element) | ||
return label | ||
|
||
return self.find_radio_label(input_element) | ||
if input_element.get('type') == 'checkbox': | ||
div_parent, parents_text = self.get_div_parent(input_element) | ||
if div_parent == 'None' or parents_text == 'None': | ||
pass | ||
elif div_parent and parents_text: | ||
#return div_parent, parents_text | ||
checkbox_values = [div_parent, parents_text] | ||
return checkbox_values | ||
|
||
return [div_parent, parents_text] |
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 CompanyWorkflow.get_label
refactored with the following changes:
- Use named expression to simplify assignment and conditional [×10] (
use-named-expression
) - Inline variable that is immediately returned [×2] (
inline-immediately-returned-variable
) - Use x is None rather than x == None (
none-compare
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
This removes the following comments ( why? ):
# Case 6: Check if the input_element has a placeholder attribute
#return div_parent, parents_text
if current_level == 0 or current_level == 5: | ||
if current_level == 0: | ||
print(element.prettify()) | ||
if current_level == 5: | ||
sauce = element.next_element.get_text(strip=True) | ||
print(sauce) | ||
return sauce | ||
if current_level == 0: | ||
print(element.prettify()) | ||
elif current_level == 5: | ||
sauce = element.next_element.get_text(strip=True) | ||
print(sauce) | ||
return sauce |
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 CompanyWorkflow.find_radio_label
refactored with the following changes:
- Hoist conditional out of nested conditional [×2] (
hoist-if-from-if
) - Simplify conditional into switch-like form (
switch
)
print("Result #" + str(self.job_links_counter) + " from Google Seaech") | ||
print(f"Result #{self.job_links_counter} from Google Seaech") |
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 scraperGoogle.print_google_search_results
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
) - Remove unnecessary calls to
str()
from formatted values in f-strings (remove-str-from-fstring
)
Branch
main
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run:Help us improve this pull request!