-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add buttons to ruff rule embed #68
Conversation
This PR is being deployed to Railway 🚅 byte: ◻️ REMOVED |
…69) Co-authored-by: Alc-Alc <alc@localhost>
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.
PR Type: Enhancement
PR Summary: This pull request introduces an enhancement to the Ruff rule embeds within the application. It adds interactive buttons that allow users to collapse, expand, and delete Ruff rule embeds. This feature aims to improve user interaction with the application by providing a more dynamic and engaging way to view and manage the display of Ruff rule information.
Decision: Comment
📝 Type: 'Enhancement' - not supported yet.
- Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
✅ Small diff: the diff is small enough to approve with confidence.
No details provided.
General suggestions:
- Consider adding user feedback or confirmation messages upon interaction with the buttons to enhance user experience and provide clear communication of actions taken.
- Review the accessibility of the buttons to ensure they are easily usable for all users, including those with disabilities.
- Ensure that the addition of these interactive elements does not significantly impact the performance of the application, especially in environments with high user interaction rates.
src/byte/plugins/astral.py: Simplify the implementation by integrating new features directly into the existing `embed` structure to reduce complexity and improve maintainability.
While the new features introduced in this change, such as docs_field
and minified_embed
, add functionality, they also increase the complexity of the code. The addition of a separate minified_embed
object alongside the original embed
object requires developers to track two closely related but distinct objects, which can make the code harder to maintain. Additionally, the introduction of RuffView
adds a new dependency that could complicate future maintenance.
A simpler approach might be to refactor the code to improve readability and maintainability without adding unnecessary complexity. For example, we could streamline the addition of the docs_field
directly into the embed
object without creating a separate minified_embed
. This would keep the focus on enhancing functionality while minimizing the introduction of new variables and logic that could make the codebase harder to understand and maintain. Here's a suggested simplification that incorporates the new docs_field
while maintaining the original structure of the code:
if (rule_details := self._rules.get(rule)) is None:
embed = Embed(title=f"Rule '{rule}' not found.", color=0x261230)
await interaction.followup.send(embed=embed)
return
formatted_rule_details = format_ruff_rule(rule_details)
docs_field = (
f"- [Rule Documentation]({formatted_rule_details['rule_link']})\n"
f"- [Similar Rules]({formatted_rule_details['rule_anchor_link']})"
)
embed = Embed(title=f"Ruff Rule: {formatted_rule_details['name']}", color=0xD7FF64)
embed.add_field(name="Summary", value=formatted_rule_details["summary"], inline=False)
embed.add_field(name="Documentation", value=docs_field, inline=False)
embed.set_thumbnail(url=ruff_logo)
for idx, chunk in enumerate(chunk_sequence(formatted_rule_details["explanation"], 1000)):
embed.add_field(name="" if idx else "Explanation", value="".join(chunk), inline=False)
embed.add_field(name="Fix", value=formatted_rule_details["fix"], inline=False)
await interaction.followup.send(embed=embed)
This approach aims to enhance the code's maintainability and readability by reducing the number of moving parts and focusing on the essential functionality needed.
Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨
* feat(astral-ruff): Minimal response and ephemeral expand * Update src/byte/views/astral.py --------- Co-authored-by: Alc-Alc <alc@localhost> Co-authored-by: Jacob Coffee <jacob@z7x.org>
Pull Request Checklist
Description
Close Issue(s)