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

Sourcery Starbot ⭐ refactored Style77/quantex #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the develop branch, then run:

git fetch https://github.com/sourcery-ai-bot/quantex develop
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -36 to -41
news = r.scalars().first()
if not news:
if news := r.scalars().first():
return [NewsModelDTO.from_orm(news)]
else:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="News not found"
)
return [NewsModelDTO.from_orm(news)]
Copy link
Author

Choose a reason for hiding this comment

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

Function NewsDAO.get_news refactored with the following changes:

@@ -49,7 +49,6 @@ def register_startup_event(
@app.on_event("startup")
async def _startup() -> None:
_setup_db(app)
pass
Copy link
Author

Choose a reason for hiding this comment

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

Function register_startup_event refactored with the following changes:

Comment on lines -71 to -72
pass

Copy link
Author

Choose a reason for hiding this comment

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

Function register_shutdown_event refactored with the following changes:

chromedriver_path = os.path.join(
current_directory, "driver", "chromedriver"
)
return chromedriver_path
return os.path.join(current_directory, "driver", "chromedriver")
Copy link
Author

Choose a reason for hiding this comment

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

Function get_chromedriver_path refactored with the following changes:

Comment on lines -51 to +61
if unit == "s":
delta = timedelta(seconds=int(value))
elif unit == "m":
delta = timedelta(minutes=int(value))
if unit == "d":
delta = timedelta(days=int(value))
elif unit == "h":
delta = timedelta(hours=int(value))
elif unit == "d":
delta = timedelta(days=int(value))
elif unit == "m":
delta = timedelta(minutes=int(value))
elif unit == "s":
delta = timedelta(seconds=int(value))
elif unit == "w":
delta = timedelta(weeks=int(value))
else:
raise ValueError("Invalid timestamp unit")

normal_datetime = datetime.now() - delta

return normal_datetime
return datetime.now() - delta
Copy link
Author

Choose a reason for hiding this comment

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

Function convert_relative_timestamp refactored with the following changes:

Comment on lines -422 to +417
if len(results) > 0:
if results:
Copy link
Author

Choose a reason for hiding this comment

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

Function NewsScraper.scrape refactored with the following changes:

Comment on lines -514 to -518
edenai_key = os.getenv("QUANTEX_EDENAI_API_KEY")
if not edenai_key:
if edenai_key := os.getenv("QUANTEX_EDENAI_API_KEY"):
return user, password, edenai_key
else:
raise Exception("Missing EdenAI API key")

return user, password, edenai_key
Copy link
Author

Choose a reason for hiding this comment

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

Function preconfigure refactored with the following changes:

self.api_url = "https://api.telegram.org/bot{}/".format(token)
self.api_url = f"https://api.telegram.org/bot{token}/"
Copy link
Author

Choose a reason for hiding this comment

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

Function TelegramBot.__init__ refactored with the following changes:

r = requests.post(self.api_url + "sendMessage", data=data)
r = requests.post(f"{self.api_url}sendMessage", data=data)
Copy link
Author

Choose a reason for hiding this comment

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

Function TelegramBot.send_message refactored with the following changes:

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