-
Notifications
You must be signed in to change notification settings - Fork 7
Feature/prompt user to paste code properly 35 - Take 2 #137
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
base: main
Are you sure you want to change the base?
Feature/prompt user to paste code properly 35 - Take 2 #137
Conversation
Ignore flake8 for unsupported line in constants
Thanks for having a look at this! I'll try to review in the coming days. |
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.
Thanks for this. I left some comments. I am not too sure about the mypy errors relating to the plugins. For guesslang not being found you can add guesslang.*
to the excludes: https://mypy.readthedocs.io/en/stable/config_file.html#confval-exclude
@@ -0,0 +1,23 @@ | |||
from typing import Optional |
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.
I don't much like the name of this file, can it be utils? Or whatever is more appropriate.
def get_parser( | ||
message: hikari.Message, | ||
) -> Optional[Union[HTMLParser, PythonParser, JavascriptParser]]: |
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.
We're on 3.10 (which reminds me, should probably upgrade to 3.11), so we can do:
def get_parser( | |
message: hikari.Message, | |
) -> Optional[Union[HTMLParser, PythonParser, JavascriptParser]]: | |
def get_parser( | |
message: hikari.Message, | |
) -> HTMLParser | PythonParser | JavascriptParser || None: |
Additionally... Couldn't this be:
def get_parser( | |
message: hikari.Message, | |
) -> Optional[Union[HTMLParser, PythonParser, JavascriptParser]]: | |
def get_parser(message: hikari.Message) -> CodeblockParser | None: |
NamedTuple( | ||
"MarkdownCodeblock", | ||
[ | ||
("content", Optional[str]), |
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.
("content", Optional[str]), | |
("content", str | None), |
return f"`{text}`" | ||
|
||
|
||
def codeblock(text: str, language: Language) -> Optional[str]: |
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.
def codeblock(text: str, language: Language) -> Optional[str]: | |
def codeblock(text: str, language: Language) -> str | None: |
I guess for the plugin stuff in mypy, maybe just |
It's probably unlikely I'm going to get back around to this. |
This is another attempt at #42
I squashed the commits, rebased on main, and resolved most of the mypy issues. The Plugin concerns already exist in
nag
, so I'm not sure how to handle those.I also pinned the new dependency to a specific commit to help avoid security issues down the road. However, this makes the build more fragile.