Skip to content

Sourcery Starbot ⭐ refactored Style77/quantex - #1

Open
SourceryAI wants to merge 1 commit into
joachimhodana:developfrom
SourceryAI:develop
Open

Sourcery Starbot ⭐ refactored Style77/quantex#1
SourceryAI wants to merge 1 commit into
joachimhodana:developfrom
SourceryAI:develop

Conversation

@SourceryAI

Copy link
Copy Markdown

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
Copy Markdown
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:

Comment thread quantex/web/lifetime.py
@app.on_event("startup")
async def _startup() -> None:
_setup_db(app)
pass

Copy link
Copy Markdown
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 thread quantex/web/lifetime.py
Comment on lines -71 to -72
pass

Copy link
Copy Markdown
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:

current_directory, "driver", "chromedriver"
)
return chromedriver_path
return os.path.join(current_directory, "driver", "chromedriver")

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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:

def __init__(self, token):
self.token = token
self.api_url = "https://api.telegram.org/bot{}/".format(token)
self.api_url = f"https://api.telegram.org/bot{token}/"

Copy link
Copy Markdown
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:

def send_message(self, chat: str, text: str):
data = {"chat_id": chat, "text": text, "parse_mode": "markdown"}
r = requests.post(self.api_url + "sendMessage", data=data)
r = requests.post(f"{self.api_url}sendMessage", data=data)

Copy link
Copy Markdown
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