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
Daria/thread names #27
Conversation
Quick response, as I'm in a forest: The test function must start with "test_" prefix. I'm sorry! It's not obvious, it's a magic pytest convention. The same way xUnit prescribes method names. |
@honzajavorek Thank you! Ofc I missed that. |
I’m sorry for the lost hours! 😀 Easy to overlook. Im happy I could provide
second eyes. This is one of the things which are easy to spot on GitHub,
but I’m sure I could end up with the same problem myself!
…On Mon 14. 8. 2023 at 18:25, Daria Grudzien ***@***.***> wrote:
@honzajavorek <https://github.com/honzajavorek> Thank you! Ofc I missed
that.
—
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACFGMPMO4DVNEJQVDV6BGDXVJGRHANCNFSM6AAAAAA3PXPOH4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
juniorguru_chick/lib/thread_names.py
Outdated
1. Check if the message includes text in brackets, if yes: | ||
a. Remove brackets | ||
b. Remove spaces | ||
c. Check if the message includes text between colons |
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 think there will never be text between colons just like that. User types it there like :css:
, but Discord translates it into either:
- Custom emoji, and it becomes
<:css:842343369618751519>
- Unicode emoji, and it becomes
🐍
For simplicity, I'd keep them as they are. Treat them as if they're any other words, and if that becomes a problem, let's fix that in the future. In such case, I think it should be enough to:
- See if the beginning (leading whitespace not breaking the algorithm) of the message has a match for
[
, followed by multiple "anything else than]
", followed by]
. - If yes, take the "anything else than
]
", split it by commas, strip trailing white space. - Join the resulting list back to a string and turn it into a thread name as you like.
- Keep the original message as is, we're just naming threads.
- If there are no brackets at the beginning, name the thread by the current weekday.
Potentially useful links:
- https://regex101.com/
str.lstrip()
,re.match()
,str.strip()
,str.join()
- Python's verbose regular expressions allow for less headaches, see e.g. this
Also, the dispute whether to add walrus operator to Python or not did cause Guido to step down as a BDFL, but in the end we have it! Checking results of re.match
and re.search
can be one line shorter now: if match := re.match(...):
Ofc, I understand it's not for everyone, so up to you. (Just for those brave enough to roll on the beach with walruses, muhaha).
@honzajavorek Thank you for the great tips! |
@dariagrudzien You did well, I understood perfectly. Initially I did pass over the meat of the thing, but later I found myself having a bit of time and voluntarily decided I might read the rest and drop a few comments in case I see opportunity to help. Hoping that those won't be taken as unsolicited advice 😅 |
@honzajavorek As long as everyone wins, we're good! |
527296c
to
fd6a723
Compare
I decided to take a step back and try TDD. Added passing & failing tests. |
7ddc278
to
3fb24c6
Compare
3fb24c6
to
3be76b2
Compare
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.
As far as the tests pass, I found no blockers! Made a few suggestions, but up to you.
Only now I realized the name is now composed from just the words, but in #10 the idea is more like „Past na Honza Javorek: algoritmy“ instead of „Čtvrteční past na Honza Javorek”. I think we can improve it this way as a next step in a separate PR though.
Welp! I got stuck trying to run a basic test o.O
Please disregard the actual meat of the thing. This is my first time with Pytest and parameters, and I'm surprised that I don't see the new test in the report. I checked the
pyproject.toml
for config and I don't understand why this wouldn't run.Also for fun when I started at least I was seeing
run-last-failure: 4 known failures not in selected tests
. Now in pycache directories I see files with the.pyc
extension hinting at some assertion errors. When I try to run the specific test file, Pytest doesn't collect any items.What am I missing?