#dev-contrib
1 messages · Page 5 of 1
I would like to start contributing to anything really, to help me learn more how can I go about it?
!contrib
Contribute to Python Discord's Open Source Projects
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!
Projects to Contribute to
• Sir Lancebot - our fun, beginner-friendly bot
• Python - our utility & moderation bot
• Site - resources, guides, and more
Where to start
- Read our contribution guide
- Chat with us in #dev-contrib if you're ready to jump in or have any questions
- Open an issue or ask to be assigned to an issue to work on
@modest star ^
Thanks, will take a read of all the info etc 🙂
How are you running the tests again, did you only run the single file or all of them?
Are there any PRs needing review more than others?
well bot#2234 has been up for a bit and is a pretty common frontend thing, associated implementations have already been deployed on site
I wouldn't really say it's critical though 😅
bot#2017 is marked as p1 and needing review
All of them
Whatever the one for the test server is
hm, screenshot your test config?
Not on my laptop atm
not sure why you're getting the redis issue though, weird
I don't think I have a test config?
usually my auto config works (just right click tests folder and run)
oh? lemme try
oh yeah mine is broken as well
for poetry run task test
I guess the difference is that the poetry test task is with pytest-xdist parallel mode
and the pycharm test is not with parallel
double check that poetry in terminal is using the poetry env that was setup and updated by pycharm
if you run poetry install --remove-untracked in terminal, does it change any packages?
It didn't when I did it
❯ poetry install --remove-untracked
Installing dependencies from lock file
No dependencies to install or update
Installing the current project: bot (1.0.0)
When you run the tests, how many runners does it spawn?
10
interesting, I just dropped mine to 10 and it has the same failures
was your auto higher?
32 fails as well
4 -> Fail
8 -> Success
16 -> Fail
32 -> Fail
-n 1 works fine
I run with 4 locally and it works for me, might depend on your cpu
Sooooooo, I have a fix
I'm not sure if it's too much of a hack though
Scaleios
you are judge, jury and executioner
There’s no such thing as too much hack
well....since all the RedisSession is a singleton, I just put redis_instance = RedisSession(use_fakeredis=True) in tests.__init__.py
So a redis session is initialised before any tests run
xdist weirdness, with some number of workers a redis session isn't created
Why do you think this is a hack
the init file is empty, it just has logs 😅
I mean it works
fwiw, all the redis tests inherit from this class ```py
class RedisTestCase(unittest.IsolatedAsyncioTestCase):
"""A very good docstring."""
session = None
async def flush(self):
"""Another great docstring."""
await self.session.client.flushall()
async def asyncSetUp(self):
self.session = await RedisSession(use_fakeredis=True).connect()
await self.flush()
async def asyncTearDown(self):
if self.session:
await self.session.client.close()
I am guessing some of the tests are getting thrown to workers that didn't have this setup
which doesn't make sense, since I thought this would be ran before all tests
and it's odd that it only works with a certain number of workers
everyone's mileage will vary too, since the number of workers depends on the cores on your CPU
it depends on host cpu lol
it's some combination of the silence tests
They are the mains ones that use this super class
I wrote a large portion of them, and I’m not sure if I used that class or not
you didnm't
this class is new
Well
it's based on a class you wrote
I just moved it to base.py so that another test suite could use it
The reschedule and unsilence tests don’t seem to use it
Maybe connecting this many times isn't a good idea
they didn't need redis
I wonder if the reconnecting is causing the issue
I wonder if this is actually caused by each time RedisSession is called there is a small window where cls._instance is set to none
hmmm no it shouldn't do, since that metaclass won't do that
For some reason, running the test command just floods my terminal with thousands of exceptions ```py
Current thread 0x File "C:\Python\Python310\lib\traceback.py", line 121, in print_exception
KeyboardInterrupt:
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
Windows fatal exception: code 0xc0000374
I have no idea what's happening lol
Seems pyreadline3 was broken in some way, re-installing that fixed it
Interesting, I got the test failures you described on my normal setup
However, it's definitely unsilence tests
That's too much text, but all 7 are unsilence lol
lemme try add RedisTestCase onto that
It didn't seem to pass with that yet, no
Does the asyncsetup run before or after the regular one
after
Ah, i see why now
we do asyncio.run(self.cog.cog_load()) within the setUp function
The failures are in the setup yeah
which calls through to _rescheulde
which has some redis things
we could move that to asyncSetUp
calling super first
That sounds perfect yeah
We might need to move some of the other setup too
Something like this seems to have done the trick:
async def asyncSetUp(self):
"""Load cog instance, and populate attributes."""
await super().asyncSetUp()
overwrites_cache = mock.create_autospec(self.cog.previous_overwrites, spec_set=True)
self.cog.previous_overwrites = overwrites_cache
# Populate instance attributes.
await self.cog.cog_load()
overwrites_cache.get.return_value = '{"send_messages": true, "add_reactions": false}'
But it seems we still have one possibly unrelated failure
> self.cog.notifier.remove_channel.assert_called_once_with(self.text_channel)
E AttributeError: 'function' object has no attribute 'assert_called_once_with'
tests\bot\exts\moderation\test_silence.py:795: AttributeError
Which should have been created after cog_load
yea I'm seeing the same
Let me get a debugger in
Oh maybe it's the mocks
Would they propagate to the asyncsetupup too hmm
Nop
Yea, I'm guessing the cogload in the async setup is wiping out the autospec
Nah
We just need to mock the SilenceNotifier
The other things since they are instance values remain unchanged
@autospec(silence, "SilenceNotifier", pass_mocks=False)
With this, my tests are passing again
bot#2252
The unsilence test set up only needs to mock the notifier too
With the one on your PR, or after making this change?
is your change to delete the @autospec(silence.Silence, "_reschedule", pass_mocks=False) from the setUp func?
if so, both
No so, in the normal setUp, we only need _reschedule and Scheduler. In the asyncSetUp, we need only SilenceNotifier
Originally, all 3 are mocked in the setUp
Silence tests would be the same deal
We should probably move this stuff to a base silence test class
Sort of yes and no, it's not inherited, but the super will be mocked as it was
I'm still struggling a bit with a few things that seem to be mock issues in our util mocks
hmmmm, slightly stuck on sorting out the asyncSetUp of UnsilenceTests
Wait let me show you what I have
Not sure if discord voice calls work, I'll try
wait a sec
Oh oh, discord is telling me I entered an invalid 2fa code
Can you hear me?
bot#2252 a beautiful pr
made with love from your local <@&409416496733880320> team
:)
hey @fossil veldt @static canyon could you pull this PR and see if it works locally for you?
I've ran this using a few different worker setups, all seems to be working my end
xdist seems to work now yeah 👍
very cool
I've not got access to laptop for next few days so can't unfortunately 
The number of workers determines how the tests are split, so with certain numbers, they'd be split up across a worker which did init, and one which did not
If you have time, drop a review on the PR
I feel like we could do with some standardisation on how we want to do datetime stuff in the bot, or maybe a guide on what to use when. There are often a load of ways that 'work', but i'm never sure which is ideal. For example, which of these do we use when?
datetime.utcnow()datetime.now(tz=timezone.now)datetime.now()and then do.replace(tzinfo=None)on what you're comparing it toarrow.utcnow()arrow.utc(tz=timezone.now)
And should we use dateutil.relativedelta or datetime.timedelta?
And what are the differences between arrow.get and dateutil.parser.parse and datetime.datetime.fromxxx?
As well as our various custom utils and converters and other stuff.
We could make it standard by saying you always use arrow
and if you need a datetime object, just use the datetime prop
If we could standardize on always datetime-aware that would be fantastic. It helps for testing features where time matters but you're not in UTC
i guess one problem with that is that if we say you always use arrow, it means you will need to convert and datetimes from d.py to arrow before using them
Yea, we already have that
at least in bot.
we use aware datetimes everywhere now, it's just still a bunch of different ways to make them
1895 and 1906 were the PRs that were the recent ones
Okay, because wookie mentioned above datetime.utcnow() which is tz naive
Yea, some of the ones wookie mentioned we don't use anymore
I think if we're making new datetime objects, we should use arrow
honestly I'd vote for arrow just because it's tz-aware from the start. It's not the most obvious that datetime.utcnow() is tz naive and I feel like that's something that could slip through a code review
making all our helpers only work with arrow will mean that we need to convert to arrow objects from datetime, and then convert back when passing to d.py
urgh, i might have to ask someone else to fix the timezone issues in #2250 because docker has decided that it does not want to play nice no matter how many times i restart my computer
could you open a terminal and do wsl --list --verbose
in pwsh?
this happened to me awhile ago and unfortunately the fix was re-installing docker desktop
yea any terminal
NAME STATE VERSION
* docker-desktop-data Stopped 2
nixos Stopped 2
docker-desktop Stopped 2
Ubuntu Running 2
ahhhh i'll do that then
huh, they are shutdown
yea, maybe just reinstall docker desktop
if it that list said shutting down or running, the you could do wsl --shutdown
(and then open docker desktop)
yea sorry for the constant comments on a very small PR
timezones are weird
IG this is partially where wookie's message came from
making it standarised will make this easier
i don't like the organization of datetime in the stdlib at all honestly
(if it's possible)
agree lol, backwards compat is the blocker on better libs
which is why arrow is nice
When I moved everything to be timezone aware, there were a couple of instances where using datetime.now(tz=timezone.utc) seemed easier, don't recall why. But otherwise it's all arrow.
Also arrow.utcnow doesn't need timezone.utc because it's already utc
So in the same vein never datetime.utcnow() because it's not actually in utc
oh lol I just realised I typed timezone.now 🥴
- What timezone are you in?
Yes.
Just did a quick google and found this https://pypi.org/project/flake8-datetimez/, seems like it could be useful?
approval on sir-lancebot#1086 👉 👈
lgtm
I'm fine to add it if someone tests it and it seems to work
a quick glance at src, it doesn't look like it exfils my discord token
hm although it does suggest using datetime as the fix in some of the errors, where we might want to use arrow instead
inb4 pydis flake8 plugin??
What more can you ask for?
we could fork and change the messages lol
Is there a way to get a more informative output on SQL failures in django
It crops the SQL to like 15 characters, and you can't see any of the important info
Also do foreign key models in django somehow update the python objects, or does that need to be set manually
Currently I just return the call to save, so I can easily set it on the linked object
Can anyone check sir-lancebot#1085 please?
@timid sentinel @hoary haven different configs of line breaks and periods
what do we think 
That guy sure is spamming a lot
Good thing it's not @fossil veldt
what do you think though, 1 period, 2 period, or 2 with line break
What about on the next line down?
Basically your last one without the blank lines
I like that
On a new line so it catches people's attention and doesn't get lost at the end of text, and doesn't have any extra blank space
Could even actually mention the role to draw more attention to it
won't moderator get double pinged then
allowed_mentions=None
hm..
Oh wait - Can you use that outside of an embed?
but we want to mention the muted guy right?
Fair
allowed_mentions=[muted_guy]?
i like having the 2 line breaks
yeah I think I like that one also?
The empty line in between looks better to me
I'll try the non-mention pinged one as well
What would be the benefit of doing that, Shen?
Mention the role to get pretty colors to draw the readers attention
Tell it not to ping to avoid duplicate pings because you already get a ping in #mod-alerts
Ah, so you're saying - yeah I getcha
I like that
Also lets users "see the ping"
I'm indifferent either way
Lots of people don't necessarily understand that mods have been pinged privately - adding the pretty colors here would physically show them that "mods have been pinged"
Though I guess that is the point of adding this sentence in the first place
I think you should add an article before the role ping
But otherwise I like this (definitely prefer the ping part on a new line)
like The Moderators have been alerted for review. ?
Yeah
hmm
Keeping the ping
^ has my vote
ping for others involved in this issue: @wild prism @vocal prairie thoughts between the above options?
Imo this but with an article
I'm fine with the newline between and I like the ping. I don't really have a preference for the exact wording
does the mention actually ping
it does not
I don't mind the wording either way
i guess i'd go with the article
Alright I updated it to the article version as of latest commit ^
@vale ibex should we standardize the use of the flag keyword argument one way or the other? The discord invite is using it while the other 2 are positional.
botcore/utils/regex.py line 15
flags=re.IGNORECASE```
botcore/utils/regex.py line 35
re.DOTALL | re.IGNORECASE # "." also matches newlines, case insensitive```
Yea, feel free to do that if you like
also I added unit tests for both re.search and re.match
https://github.com/python-discord/bot-core/blob/invite-regex/tests/botcore/utils/test_regex.py
since previously the re.search tests all passed the http/https links but it wouldn't work with re.match
Cool Cool, sounds good
Since bot-core is on 3.10, can't we use the new <type> | None type hints?
https://github.com/python-discord/bot-core/blob/invite-regex/tests/botcore/utils/test_regex.py#L2
tests/botcore/utils/test_regex.py line 2
from typing import Optional```
Do we have a specific style guide banning the new ones, or can they be used going forward?*
you can if you want, I don't see the need in replacing existing optionals.
Personally I prefer the optional wrapper if it's a simple hint
So just developer preference for now? Sounds good.
Actually - Has a deprecation timeline been announced for Optional and Union? They seem to have escaped the deprecation warnings plaguing the rest of the module
There's no deprecations for those, no
Why?
I think in strict 3.10+ codebases the preferred way will likely be | None
that's a question for the psf :D
Why? The Optional name is horrible
probably just familiarity if I had to guess
I think it’s more explicit about intentions, but that might also be ^
Yeah - I'm just wondering why.... Probably because they made the big sweeping deprecations in 3.9, and the | wasn't added until 3.10
but I literally made the branch like 10 minutes ago
You don’t need to use the netlify script locally tho
this is in ci
Oh right, Chris hasn’t merged my PR yet
that's the ci yeah
👀
no, you haven't paid yet
was that PR ready? I thought you were making some further changes
I think all further changes are now up to site
I’m comfy in bed now, but if someone extends the timeout to 15-20 seconds, I’ll review it
by minor version you mean 8.1.0 or 8.0.1 
pydis_site/settings.py line 30
TIMEOUT_PERIOD=(int, 5),```
this?
static-builds/netlify_build.py line 50
response = httpx.get(download_url, follow_redirects=True)```
won't line 43 timeout error first?
potentially both need a timeout setting I guess, depending on how quickly the artifact is ready
Well the request doesn’t wait until the artifact is ready
All the requests are “instantaneous”, the timeout is because we wait for the GitHub API
But yeah, put it on both
Or make a client for the entire script
is this good for the changelog 
Changelog
=========
- :release:`8.1.0 <16th August 2022>`
- :support:`124` Updated Discord Invite regex to match leading http, https, www
That’s fine too
yea looks good, just make sure the newlines are consistent
doc builder is picky
oh I need 2 new lines right
Would it be support, or feature
you can test it with poetry run task docs, that'll build the html
could be considered breaking also if someone expected match to not match https 😔
would throwing the gh token on there too be bad?
seems fine to me
heh it's probably fine
File "/Users/ionite/Library/Caches/pypoetry/virtualenvs/bot-core-3LNK_f7y-py3.10/lib/python3.10/site-packages/releases/__init__.py", line 8, in <module>
import six
ModuleNotFoundError: No module named 'six'
Throwing what token?

github api token
Run pip install six, or poetry install
It doesn’t access the GitHub api directly
(We also can’t have secrets)
Lol it’s a bit of an insane solution
The site API acts as a middle man between our build script and GitHub
seems fine I guess
I’m here
thanks
sorry this is incorrect, you have now been banned from r/pydis
but yea, it looks good :P
I’m sending you a receipt for my services
My phone plan renews tomorrow, prompt payment expected
@fossil veldt i promise wookie and i are not just obsessed with full-stops 
but uh
that full stop is actually already applied down-stream https://github.com/python-discord/bot/blob/automute-message/bot/exts/moderation/infraction/_scheduler.py#L250
bot/exts/moderation/infraction/_scheduler.py line 250
await ctx.send(f"{dm_result}{confirm_msg}{infr_message}.", allowed_mentions=mentions)```

oooooo you got me
I could change it back up I guess, but that was the original form before
mm i have no opinion on this
I'll leave it I guess? Since it's joining 3 other messages which may be empty and expecting a shared full stop? 
yes you can dismiss my comment
Can anyone check sir-lancebot#1085 please?
done
🎉
@timid sentinel how would you handle possible abuse of someone doing a raid opening as many as they can until we're capped at active threads?
This limitation is also to try to handle not reaching that cap. It should be on the person who is seeking help to make the thread
We could also have a cooldown thread create role which removes the permission to create threads
how would you handle possible abuse of someone doing a raid opening as many as they can until we're capped at active threads?
We could do it similarly to how we do other anti-spam stuff, still having a limit over a range, although a larger one than just one thread
It should be on the person who is seeking help to make the thread
I'm not sure, I think it's easier for someone offering help to think "this channel is currently moving very quickly, and this might require a bit of back-and-forth to fix".
We could also have a cooldown thread create role which removes the permission to create threads
Good point, I think that would be much better than just deleting, although I still think there's a use case for making a couple of threads in a day
to support a role removing permission to make threads, we'd need to put that on a channel override, which isn't bad, just would need to be maintained similar to our muted role.
we also wouldn't be able to give permission to create threads on a channel by channel basis either. As if we add a channel override to create threads, we can't addd another channel override to remove it
as channel override permissions are additive
So we'd need to roll it out to every channel
I think the creating of a new thread is similar to a help channel. You don't open a help channel for someone else
sure, but similarly if you open a thread in a topical channel, that takes off and becomes popular, that precludes you from opening a thread elsewhere.
Adding the perm to the everyone role but removing it with an actual role should work, no?
we'd need to give it to the everyone role globally, and then remove it with another role within a channel override
permissions are additive within the same scope
IE if you have one role that removes a perm and one role that adds a perm in the global scope, the one that adds it wins
I thought the everyone role within a channel could still be overridden by an actual role
So you remove the perm in the global scope and then have everyone role allowed in the channel scope?
not sure how those two interact.
regardless, I think this applies to the concept of having a role anyway
It only blocks you for the day though, right?
unless the role is given out as a timeout as a result of our anti-spam, rather than blocking you until the thread closes
Ah, so the idea is the role would be removed 24 hours after being issued?
actually, for implementation detail, removing it at 00:00 utc might be easier
and has similar behaviour
Mhm, it's just to stop people rapid fire opening threads
or even have a task that runs each hour and removes the role from everyone might just do it
1 thread/h seems fine
I think we could get a similar raid-protection by limiting to say 5 threads a day
Yeah that's fine, my main concern comes from the abuse/raid angle. So if there's a solution that keeps that in mind I'm fine. I do want to get buy in from Zig and the mod team though
Hello folks,
I'm trying to contribute to our community's bot ( First time ) so before I begin, I wanted to ask this:
Can I find environment setup instructions & how to launch the bot somewhere ? Or do I need to figure that out on my own ?
!contribute
Contribute to Python Discord's Open Source Projects
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!
Projects to Contribute to
• Sir Lancebot - our fun, beginner-friendly bot
• Python - our utility & moderation bot
• Site - resources, guides, and more
Where to start
- Read our contribution guide
- Chat with us in #dev-contrib if you're ready to jump in or have any questions
- Open an issue or ask to be assigned to an issue to work on
we have a contribution guide
Perfect ! Thanks a lot 😄
When trying to run sir lancebot locally, I did poetry run task start and it outputs this 2022-08-17 17:58:32 | bot.utils.decorators | INFO | Starting seasonal task EasterFacts.send_egg_fact_daily (April) 2022-08-17 17:58:32 | bot.utils.decorators | DEBUG | Seasonal task EasterFacts.send_egg_fact_daily sleeps in August 2022-08-17 17:58:32 | bot.utils.decorators | INFO | Starting seasonal task PrideFacts.send_pride_fact_daily (June) 2022-08-17 17:58:32 | bot.utils.decorators | DEBUG | Seasonal task PrideFacts.send_pride_fact_daily sleeps in August
But gets stuck here (these are the last 4 lines it outputted)
That seems fine?
Did the bot start?
Well it starts the server so it should keep going until you Ctrl+C to close it
Does lancebot have a reload/load cog command?
.help ext
**```
.extensions
**Can also use:** `c`, `cogs`, `ext`, `exts`
*Load, unload, reload, and list loaded extensions.*
**Subcommands:**
**`list `**
*Get a list of all extensions, including their loaded status.*
**`load [extensions...]`**
*Load extensions given their fully qualified or unqualified names.*
**`reload [extensions...]`**
*Reload extensions given their fully qualified or unqualified names.*
**`unload [extensions...]`**
*Unload currently loaded extensions given their fully qualified or unqualified names.*
Thank you
In lancebot, I added this line in another class. It accesses the Bookmark class (the commands.Cog)and calls the action_bookmark. But I get this error: ```py
await Bookmark.action_bookmark(self.channel, interaction.user, self.target_message, self.title)
TypeError: action_bookmark() missing 1 required positional argument: 'title'
the action_bookmark function is ```py
@staticmethod
async def action_bookmark(
self,
channel: discord.TextChannel,
user: discord.Member,
target_message: discord.Message,
title: str
) -> None:
Actually I think I'm missing self
I thought it would be done automatically
Did you make action_bookmark a static method?
static methods don't have self inserted automatically.
self is a reference to the current instance of the class, but if you're calling it statically, there isn't an instance being used
I think the real question is why are you using that method from the bookmark cog in another cog?
Its a discord.ui.View class in the same file as the cog
So now I have ```py
class View(discord.ui.View):
...
async def callback(self, interaction: discord.Interaction):
await Bookmark.action_bookmark(self, self.channel, interaction.user, self.target_message, self.title)
So here, I call `action_bookmark`. which is this function
A Discord bot started as a community project for Hacktoberfest 2018, later evolved to an introductory project for aspiring new developers starting out with open source development. - sir-lancebot/b...
not sure what I'm doing wrong with trying to embed the code, but basically action_bookmark calls a function build_bookmark_dm
This seems to raise this error Traceback (most recent call last): File "C:\Users\tenuk\AppData\Local\pypoetry\Cache\virtualenvs\sir-lancebot-gb-kPGWv-py3.9\lib\site-packages\discord\ui\view.py", line 359, in _scheduled_task await item.callback(interaction) File "C:\Users\tenuk\sir-lancebot\bot\exts\utilities\bookmark.py", line 33, in callback await Bookmark.action_bookmark(self, self.channel, interaction.user, self.target_message, self.title) File "C:\Users\tenuk\sir-lancebot\bot\exts\utilities\bookmark.py", line 78, in action_bookmark embed = self.build_bookmark_dm(target_message, title) AttributeError: 'SendBookmark' object has no attribute 'build_bookmark_dm'
I got passed this maybe not in the ideal way
For the solution to the above issue, is this bad? (this is example code) ```py
class Button(discord.ui.Button):
def init(self, func, ...):
self.func = func
...
async def callback(self):
await self.func()
def somefunc():
pass
view = discord.ui.View()
view.add_item(Button(somefunc))
You're awaiting a non-async function there
But otherwise that seems possibly okay
@timid sentinel thanks for the review on bot#2017, it should all be addressed now 👍
The tests on bot#2031 are failing on GitHub but pass locally?
Made a brand new blank CodeSpace, and ran the tests, and they failed for me too
How do I fix them when I don't have the errors to debug?
I've done git pull etc. to make sure my code matches
Is that env using 3.10?
Yeah, I'm not exactly sure why, so I don't really know what to tell you.
Try making a CodeSpace?
CodeSpaces != Dev Containers
You can create one directly from the "code" button on github.com, and it opens as a browser tab
Ah, right
Might not be the most comfortable for you, but it would work... at least theoretically
Hm... Nevermind then. I have no idea how to get it to show up. It's not technically supposed to be available to PyDis on our current billing plan, but it shows up anyway for me. But I have absolutely no clue what causes that, or how to make it work for other people.
You could try devcontainers, but that's a chunk more involved
Eh, don't really fancy that
it shows up for me on firefox
works for me on incognito too
https://github.com/settings/codespaces does this link work for you?
Just tried on chrome and it didn't show
Nope, gives a 404
What does this say?
https://github.com/features/codespaces/signup
I thought it was GA already
It loads and gives a form to fill out
This doesn't feel like the right approach for getting the tests in the same state locally though
Codespaces is rolling out progressively on August 11th, 2021 and can be enabled in settings by organization owners for Team and Enterprise Cloud plans. For users in individual plans, we’re extending the existing Codespaces beta. For those in the beta, access will remain and we’ll share updates on what’s coming in the near future.
I agree
I'd... start by recreating the venv and deleting __pycache__ folders?
Maybe
Ugh, recreating the venv
I've had to do that like 10 times since the 3.10 change
But yeah, I can try ig
I don't really think the venv itself would be causing something like this, I'd think it'd be more like the pycache or the testing cache, but I'd go ahead and kill it all, just to see
So should I delete .pytest_cache too?
I would
That's my thing - I always kill all the caching first, because I hate chasing my tail trying to figure out WTF is wrong, when everything is actually correct, it's just still using the cached version
Redoing the poetry env atm
Have deleted all the caches
Including mypy caches just because why not 🤷
Rerunning tests now
And.... they're still running fine
nice
Indeed lmao
Don't even remember fixing them 🤷
Guess that's what happens when you do coding at like 4am though because you can't sleep
🎉
Nice
Looking at the commit, I remember now
The issue was just that we weren't setting the created_at attr of the mock incident messages
And so msg.created_at was a magicmock thing rather than a datetime object
I was wondering how that worked
Does any nonexistent attribute just resolve to a MagicMock()?
I guess so yeah
huh
I guess that makes sense
Took me a bit to understand what I was looking at though
Yeah, I seem to remember it took me a bit to realise too
Simple fix though at least
inb4 the countless messages in here asking when we're updating to d.py 2.0 now that it's released :P
Are there significant changes from the commit we're on?
none that would affect us
at least for bot & sir-robin
sir lance hasn't been bumped for a while, so hasn't got all the async changes yet
For the buttons that sir lancebot uses, are they persistent through bot restarts, or just persistent while the bot is running?
In which event or function do you suggest adding it? I'm not that familiar with discord.py now (i use disnake)
The use of persistent views is the same in d.py as it is in disnake.
So you can do the same as what you are familiar with in disnake
in disnake, I add it with on_ready because I was told there's a bug and because of that I should use on_ready for it even though it's not ideal
You could also add it in the bot's setup_hook
when to use persistent views is a different question
if the view is going to be in a channel that anyone can talk it, we probably don't need a persistent view
do you mind giving an example of that? Never used it before
since the view itself is going to disappear in 5 minutes to the history
bot/bot.py line 60
self.add_view(JamTeamInfoView(self))```
And the button is for the bookmark message that gets sent to the users DM's
so yeah I'd need it
Ah right, what would it do?
oh okay. thank you
What is the button in the DM going to do?
Seems alright. I'd suggest opening issues for changes like that in future though,
Just so that you don't waste your time if we don't want the change.
Yeah..i should have. https://github.com/python-discord/sir-lancebot/issues/932#issuecomment-1217915167 was the original issue
Description Right now, bookmarking messages as someone who is not the command invoker requires adding a reaction. I believe that the system can be made much more better using buttons as it greatly ...
Yep
@fossil veldt hey ionite, trying out bot#2234 - are there additional changes to be made for when infractions are edited & DMs resent?

sorry is the scope of this PR just for the public messages on the server?
what duration edit did you make again?
i noticed the DM for the original 1 hour mute shows just the "x hours" for duration
initially a 1 hour mute, edited to 2h and then 4h
huh..
why did it say duration (duration remaining) in the first place?
seems... redundant?
don't quote me on this, but i believe it's to account for a potential delay in between the infraction being issued and the database being updated?
which is why we always had the X hours 59 minutes remaining everywhere.. right?
ah no I see why
the resend command can potentially send the DM hours later
so remaining and duration could be different
yeah see my review
ah right I see wookie's review as well
the added kwarg of resend makes sense yeah
though do we really need the remaining anyways?
would total duration and the relative time stamp be enough? Resend or not?
If we have a relative timestamp I don't think we need the remaining string
I get the intention, to make it extra clear that that duration is not from when the message was sent when resending the PR, but I don't mind if we remove it.
I mean I don't really know in what scenario the resend infraction dm really gets called so
I'll keep it with the kwarg I guess
mobile user detected
yeah so I'm testing it with the resend kwarg, but since edit infraction doesn't actually send a DM, to do a edit & send dm, the duration would always at least be off
since it's 2 separate commands
I don't know how often resend is used with duration edits but I assume often together...?
current state of doing an edit and a resend dm right after
I mean we could add a command argument to the actual resend command whether to send the additional remaining duration...?
I think in that case it makes sense though, it is technically slightly off, as the resend was done slightly after the edit
This seems a bit out of scope, I wouldn't mind considering it for a separate PR
I don't think we really use resend that much tbh, but i'm not that sure
I'll just leave it like this then?
Which bit?
edit could also have a new argument for sending a dm in one go
then it could automatically not use the resend kwarg
I don't really have an opinion in this since I don't use this stuff so it's up to you guys 😅
I think it's worth fixing the off-by-1 issue coming up sometimes in the original mute message. I don't really mind if the remaining text after the duration is completely removed, although I think i'd prefer for it to appear but only for infraction resends (which I think was the current intended behaviour).
The issue was that the "(... remaining)" was sometimes appearing for normal mutes when it was only meant for resends
And I think it makes sense for resends to make it extra clear that the duration is not from when the message was sent, but I don't really mind
I'll just leave it like this I guess
@timid sentinel @hoary haven Changes implemented in https://github.com/python-discord/bot/pull/2234/commits/06f9f48d2ec947f447824cda05d30f3fef9a3ef1
^ current behavior will be as such. No remaining time on initial DM, but only for DMs sent via the resend command
I've got 16 minutes to spare, and I want to upgrade site to 3.10
Challenge accepted
My IDE is already open, so we're practically half way there
It's ironic that in my search for a package's source, I went from a commit that migrated from pipenv to poetry, then one which migrated from poetry to pipenv
History truly repeats itself
Now from setup to poetry
Now another one from poetry to setup
This is truly a joke
@last patio you're as far back as I can trace, why was pyscopg2-binary added, and was it not possible to add it as an extra for psycopg as recommended in the readme
can't escape poetry 😔
psycopg is only for 3
3 what?
!pypi psycopg2-binary
Hmm wait was I looking at 3-binary
Yea
psycopg 3 is recommended to just use psycopg[binary]
similar doesn't exist for 2
I tried to bump it a while ago but it was non-trivial
I think sqlalch doesn't support psycopg3 yet
one of the other deps we use doesnt support 3
think it was sqlalch
I’ll dig into it later again
Yea, psycopg3 is coming with sqlalchemy 2.0
which is currently in beta 1, and can't find a reliable release date for it
and who knows how long django will take to bring it in
good morning
it saves us from compiler dependencies
Hey could we get site#764 merged, it's making testing a little hard :D
Very simple PR, literally just explicitly sets a bunch of datetimes in tests to match the original test's intentions
Thank you Chris
And thanks Wookie
Hey folks,
I'm curious, where are our site and bots hosted?
And do we have a some sort of CI / CD pipeline for it? ( Kinda a rhetorical question, but I thought I'd ask still)
I believe they're currently hosted on Linode in Kubernetes inside Docker containers.
and uhh, there's a .github/workflows folder which has all the ci/cd stuff inside it in each repo
yup, all in Linode's k8s engine
the workflows contain the CI and deployment triggers
the k8s manifests are in https://github.com/python-discord/kubernetes
EG @stable mountain is here https://github.com/python-discord/kubernetes/tree/main/namespaces/default/bot
Thanks alot!
Bumping django up to 4.1 (from 4.0) seems to bring some nasty changes for our test suite
The validation done by psycopg is now more strict on null-constrains, but we've been a little laissez-faire when defining the models in our tests
Which leads to a few failures here and there
Hm, maybe not quite actually
It seems to be specifically for auto-generated primary-keys
Thanks volcyy, I will use your belief to purchase the solution
thank you
what happened to the move to netcup?
We're still figuring out exactly what we want to do
the full migration to ansible isn't going ahead now
but we are still thinking about using the netcup servers for our infra
we'll announce something once plans are finalised
I have traced the issue we're running into all the way to the bowels of django, then psycopg, and it seems all through the data is correct. The ID field is never explicitly specified, which is fine since it's supposed to be an auto incrementing field in the database
That however does not seem to be the case for some reason
Here's the DDL for the ID column on my actual database
id serial primary key,
And here's the one for the test database
id integer not null primary key,
Not sure if that's relevant at all though, because testing a demo table with that in a separate SQL thing does work as intended
(not sure what engine either, it's just a random online runner)
Hmm, running the same SQL insert on the test database, and the actual database directly nets the same issues that I'm running into in the tests
I.E, it passes on my database, and fails on the test database
I wonder if this is something that's changed in how django creates tables
Yup, can confirm that did indeed change between 4.0 and 4.1
Not sure why it's not documented anywhere, or if this is actually intended or just a bug
On PostgreSQL, AutoField, BigAutoField, and SmallAutoField are now created as identity columns rather than serial columns with sequences.
That's all I could find.
Nothing else, though.
Might be totally wrong, but if you modify one of those fields and generate a migration, it might migrate to Identity columns.
That is related yes, but it's listed as a feature, not a breaking change, or migration step, so I don't think you're expected to run into issues with it
The migrations only define the model, the implementation of those fields lies entirely within django, so it'll have different behavior depending on which version of django, without changing the migrations
The issue is precisely that it has changed though, they are using a postgres type which does not seem to support auto incrementation for a django field type that's specifically for auto incrementation
I see that, but I meant that the migration would set the field to be an identity column in the actual database.
Oh, no that won't actually change either, because the migration runner only tracks model changes (even that very simplistically), it doesn't try to compare
I.E, it just checks that the current highest migration number == the migration number it last wrote (which is also stored in the database in a private table)
So running migrate won't change it unless it has to perform some operation which recreates the table entirely
Ah, I see. I have no idea then.
I mean, you've pointed out the right thing in the migration guide, but the issue isn't that a table isn't being migrated, but moreso that the change they made does not seem to make sense
Yeah, yeah, I see that now. 😄
Gonna check out relevant issues, though.
Nothing there, at least nothing marked as 4.1
Actually, maybe this https://code.djangoproject.com/ticket/33919
Seems to have been recognized as a bug, fixed, pushed to main, but not released yet
So perhaps a 4.1.1 fix, which is the upcoming release
Judging by other issues it shouldn't have caused trouble, I'm no professional though. 😄
I guess, it's not feasible right now, then.
Hm, I don't follow the first statement?
https://code.djangoproject.com/ticket/30511
Might have misread it though.
That issue specifically mentions the GENERATED AS portion, which is indeed necessary to make an integer field work as a serial key
It's what issue 33919 is saying
Here's a minimal repro of the issue
CREATE TABLE api_nomination
(
active boolean not null,
id integer not null
primary key
GENERATED BY DEFAULT AS IDENTITY
);
INSERT INTO api_nomination
("active")
VALUES
(true)
RETURNING api_nomination.id;
Try running the above with and without line 6
(You can also test it out here online, password aaa https://extendsclass.com/postgresql/a76313f)
Ah, I see.
null value in column "id" violates not-null constraint
Yeah, the current 4.1 release basically makes all the auto field types just regular integer columns
I mean removing the "might be edited" in specific cases, unless this isn't what you're all talking about here. It's not a bad idea but seems out of scope for this. We can't even really tell when the reason was edited atm, only the duration
Hey there, would a PR to fix typos be welcome?
It depends highly on what/where the typos are, and how many changes you're planning to make 😄
How about 19 lines throughout 12 files
Ehh probably not because it sucks for people who are working on those files in other PRs when they have to merge and figure out random changes
We had a PR that was similar in nature a while back (though more extreme), and that was a really bad time
Ah yeah fair point
If you can filter it down to things which are exclusively user facing (for example a typo in an article on our site), that's more fine
Alright, thank you 👍
Does anyone know what Discord account owns Github account "dannynotsmart"? If you see the comments on sir-lancebot#1034, you'll understand why I'm asking
Ah no, that's not what I was meaning to suggest
well, if the duration was updated, then we do have that information. It would have been edited at last_applied. And the original infraction creation time at inserted_at
yeah that part I know
If only the reason is edited then there is no indication as making changes to last_applied would change the duration
but you can't tell if the reason was changed atm
so you can't safely drop the "might have been edited" part in resend
At least for now
Hey @static canyon, do you think you're going to finish up sir-lancebot#919? I'm going through a bunch of PRs for staleness, and this one is a candidate for being closed for inactivity.
@spare plaza We did this one together, did you want to complete it? sir-lancebot#1071
Eh, idk. Most of the review comments feel a bit out of scope given that it's essentially rewriting the entire cog when the original purpose was just to move the code to organised files.
I see
I don't really have the motivation to rewrite the cog
So either we merge as-is and perhaps have another PR for tidying the code, or just close ig
hmm
Reviews are mostly things like this, or rewriting logic
right
If the purpose is just moving stuff around and it's done that without causing new issues then it's probably fine
Err
It might have an issue
Not sure if that is the case or not
If it is broken, I think just close the PR since I don't overly intend to work further on it now
Unless someone else wanted to finish it 🤷
I'll close it for now, but I'll ping hedyhli saying if they want to work on this PR, they can re-open it
Sounds good 👍
Also as a note if you get suggestions on a PR you think are out of scope it's well within your power to (and you should!) reject them.
Looks like that PR was meant to be a fairly simple change but got out of hand
especially suggestions like this that are just wrong
Yeah, pretty much
pep8 says to do return None, if you return an object elsewhere
Gtk 👍
What's Shivansh-007's (on github) username in discord?
I've forgotten
jason
where
it seems he may have changed usernames
wait a second
ah
fwiw I think the account was always Shivansh-007 (currently is) but their nick was jason
right
Whilst you're here, can bot#2017 be merged now? It has 2 approvals but one is slightly outdated
yes
Nice, thanks 👍
What the fuck
I'm not sure what I want to do with my own PR lol
?
what's up my home dog slice dog
django-distill has an actual homepage with actual content and instructions
Literally never seen it lmao

The stale one?
How much are we talking
uhh
Are we talking merge 500 commits, or create a new PR
mind blocked
Very good
I was pair programming with griff, I don't know what a completed state of the PR would look like
pinged him to see if he'd like to take over
for those of you who use vscode for python, what are your recommended extensions?
I've been using pycharm for a while and I'm seeing if I'd like vscode instead
of course the python extension, but I'm not sure besides that
Rainbow brackets is a common vsc one I think
I use PyCharm too though so am not of too much use
You can always take a look at the most downloaded extensions and see which apply to python development
true
I was just wondering if there were any specific ones in which people use for our repos
lol
You add the context menu as a new feature
- The existing person finishes and merges their existing PR
- We as a group open a discussion in dev-contrib whether we want to keep both or remove one - for example, @fossil veldt is already expressing interest in keeping both methods functional
@outer oasis
I think you're right - I was just confused because I don't know how to handle 2 PRs for potentially the same feature
Yeah, you'll both use the same backend for sending the [DMs for the] bookmarks, just they'll create a function for the command, and you'll create a... function? to add the context menu
(I don't do Discord bots, so I have no idea how they work)
You're right, a function. And most of the functionality should be the same, so either CTRL C + V or factor the backend logic into it's own function like you mentioned
And this is sort of in the same alley, we were discussing using a context menu similar to a bookmark for evals, so you type out your code in chat, right click, eval - what's your input on that?
Sounds like a good idea to me
It would also let me still run eval if I forgot to put the !e - It's a bit annoying to have to copy and paste into a new message, especially since it doesn't copy the ``` [unless you edit your message]
I remember someone saying that context menus were a bad idea because you were only able to create ephemeral messages, so you couldn't share the output of the eval - is that true?
Able, yes.I do believe the developer gets to pick if the response should be ephemeral or not, as with most interaction responses. But in this case it wouldn't make much sense for it to be a ephemeral, the whole point of an eval is so others can see it and be used as a pedagogical tool
@vale ibex left a few comments on the bookmark PR. Really only the lookup one matters
Hi @gritty wind
See above
Do you mind assigning @sharp crag to sir-lancebot#1089?
I can just assign myself lol
The core devs get upset about that
Rules and regulations and all that, you know
Oh yikes. Didn't know that. Will have to stop self assigning myself random stuff then 😳
(please don't hurt me core devs)
I think you can just assign yourself to approved issues? But you'd want a coredev to add the approved tag first
Yes, this
I can look into the issue tomorrow possibly, not sure yet but gotta go to bed
do i need to include all other branches also while forking?
No
Actually, that's a brand new feature that was just released like last month
You only need the one main branch, and then after you create the fork, you'll create a new branch for you to work on - on your fork
ok
Alright, I've got to go to bed now
Good luck!
ok, good night
Is @dusky shore supposed to trigger for ....hah?
It shouldn't, right? I managed to trigger him while having some conversations
The prefix is . so maybe that's why
...h
Yeah
That's supposed to happen
When an invalid command is given it'll recommend similar command names
...
It doesn't for just dots, but will if there's a letter after
Because the ? is making it display help or something ig
But admittedly that's not something we want
....hah
Do you think it scales with more .?
...............hah
Nah, it's consistently the same
So it doesn't scale
No clue what's causing this, but you can create an issue on the repo
A Discord bot started as a community project for Hacktoberfest 2018, later evolved to an introductory project for aspiring new developers starting out with open source development. - GitHub - pytho...
Will do, right after helping #help-cheese
.hah
Even .hah does it
There's literally a bug in a recently merged PR or something
Maybe sir-lancebot#1064
Looks like 3 people reviewed it and none of them actually tested
.ha too
It's trying to load hacktober stuff based on the error message
Other than maybe wookie
This is why reviews shouldn't be marked as approving when they haven't tested 
How should I name this
I guess Incorrect handling of invalid command name
And then in the description mention that #1064 likely caused this
Not 100% sure it did but I'm like 90% sure given that apparently the previous behaviour was just to error saying invalid
I'm assuming command.can_run somehow causes a message to be sent to Discord
Or something like that
There's definitely issues with #1064 anyway, like incorrect type-hints
I wonder if it's possible to just un-merge this and we can add reviews for what needs to be fixed
Rather than a new PR
thanks
CC @vale ibex thoughts?
Context is basically that this shouldn't've been merged because there's bugs in it & also incorrect typehints
sir-lancebot#1090 has been opened @static canyon
Likely better to PR fixes, rather than revert the commits
Aight
if checks fail when running can_run, it will raise a CommandError
try:
if not await similar_command.can_run(ctx):
log.debug(log_msg)
continue
except commands.errors.CommandError as cmd_error:
log.debug(log_msg)
await self.on_command_error(ctx, cmd_error)
continue```I suspect this is the problematic code. We should just ignore the error
which is likely handled by our error handler
Yeah
We're actually making it run the on_command_error though which we don't want
Can anyone check sir-lancebot#932 please?
Ah how great, lesson learned. 😅
I am getting an error when trying to build static previews of the site following this https://github.com/python-discord/site/tree/main/static-builds
it looks like you're using python3.8
our site requires python 3.9
oh wait, static-builds
So I'm not entirely sure the setup here
I think you may need to run python3.9 to run the static task
since it's part of our site project that requires 3.9
but the build script itself can only run on python 3.8 due to netlify not supporting higher
is that right @gritty wind ?
ok I created a new venv using python3.9 but I get another error now
https://paste.pythondiscord.com/kilofedolu
You're likely going to need to follow this to setup for site env https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/site/#2-environment-variables
A guide to setting up and configuring Site.
thanks, works now
nice nice
Yup, 3.9 for the actual build (or whatever the main project is using), but 3.8 in netlify because it’s the only supported version
If site added 3.8 support, or netlify added 3.9, we can build directly on netlify
No worries lmao, I've done the same in the past. Normally it works out but in this case it didn't 
I'd say maybe review but just leave as a comment rather than an approval. That way you're still giving feedback, but it won't mean merging without being tested
@timid sentinel wait, but why do we need the "remaining" part if we already have a relative timestamp?
This, I think the reason was to try and make it extra explicit in the case of resends, and since that was the previous intended behaviour and it was simple to keep that behaviour, I figured we'd might as well keep it.
.
hmmmmmmmmm
I mean, I don't really mind 😄
I think it was just the old behavior for all notifications, no?
Not specifically resend
It was added in the PR that added resends from what I could tell, the logic was just a bit broken and it sometimes appeared in normal notifications
I don't think the intention was to make it specific to resends, just a format for active infractions
It's also undergone a few major merges from main
So maybe something got jumbled up
Including the migration to timestamps
Yeah I think that's probably what happened
The logic for it was "add this if the current second is not the second the infraction was created"
Are you sure it's not from the current PR? This just checks if there's an expiration and if it's active
The if duration != remaining bit
Fair
The current solution looks good compared to the current state, so it's not a blocker either way
I'll just test it
Yeah that was there before I believe
For all DMs it always sent both duration and remaining time
Or rather it adds remaining time if the total duration is not exactly equal to the time the DM is sent. Which, considering the server latency it will never actually be equal? 
I'm okay with removing it though, imo that would be better for the UX as we already have the dynamic timestamp and the added message.
If you're doing that I think we should put "expires" after "duration"
Like in the embed order?
yeah
we could also have the last modified time like in the new search result?
since that is inferable now from infraction data
yeah I think I'll do this, it seems significantly more useful than a hard coded duration delta
You mean in the message to the user?
Can you make it just say "edited"?
okay yeah
Do we ping people for a code review or just wait until it gets reviewed ? (It's my first time :B)
do we still want the (maybe edited) message then?
reason += "\n\n**This is a re-sent message for a previously applied infraction which may have been edited.**"
mhm, we don't have info about reason editing yet
What PR did you submit?
even the current edit detection is only possible since we've hijacked the old inserted_at field
Should be bot#2261 and site#770
Ah, yeah it might take a few days until it gets attention
I'll take a look when I get a chance
Thanks folks!
👍
alright committed in dcd946b
It's finally here (the option to delete bookmarks) thank you 🎉
(If it was there before I just didn't see it)
It was just merged! (#dev-log message)
@fossil veldt remind me, did you add inserted_at to the post request for new infractions?
Yes
It now sends the same time for inseted_at and last_applied on the initial post
ah ok, couldn't find it in the code for some reason, I see it now
If I was making changes to x file locally and now the code to that file on github has changed, what should I do?
For more context, I was making changes to the bookmark.py file prior to the PR of removing bookmarks was merged
If the change on github has been merged to main, then just merge main and resolve any conflicts
What happens to the changes I made if I merge main
They stay unless there's a conflict
If there's a conflict the editor will ask you to write what it should now be (your version, main's version, or a mixture -- you edit the code to resolve the conflict and then tell git it's fixed)
Since it's your first time dealing with a potential conflict, maybe copy your local bookmark.py somewhere so that you don't lose anything
And how do I merge main? From github itself right?
git merge main probably
Make sure to update main first
Or you can do from github itself, but that's generally not recommended since github can't handle large conflicts
Whats the command to update main?
git pull main maybe
Okay thanks
I just use PyCharm buttons to do the commands for me tbh
git merge main might just work on its own actually
Also, is it okay if i use black fornatter on the file when PRing it?
Err don't do that
We use flake8
If you do poetry run task lint it'll tell you about any linting things that need to be changed
Whoops. I had it do it automatically on saving a file
Also, when I did the command it said already up to date
Which one?
Yeah, then you need to update your main first
Do you have any uncommited changes on your current branch?
If not, do git checkout main and then git pull
ah! that's why I got email notification, thank you 😄


