#dev-contrib

1 messages · Page 7 of 1

static canyon
#

Yes

outer oasis
#

Did we ever fix that one?

static canyon
#

Nope

#

Nothing we can do afaik

#

sir-lancebot#1087 (for reference)

outer oasis
static canyon
#

Wasn't there an issue/PR for pinning the poetry version? Maybe it's related to that?

outer oasis
#

Oh

#

Yes I just saw this

#

Hmm
Only pins the version in the Dockerfile

#

Hi @vale ibex
Please explain bot#2268
Thanks

dusky shoreBOT
outer oasis
# outer oasis Hi <@126811506632294400> Please explain bot#2268 Thanks

Our bird just opened a new PR and and the workflow failed because Poetry said the arguments passed to it were invalid.
But looks like you're now moving Poetry out of the main body and into the Dockerfile and pinning to the previous version?

Do we just need to wait and rerun the CI after your PR is merged?

karmic silo
#

have you guys considered adding some web frameworks to the eval command (just for their utilities and such), i see people asking about them a lot

outer oasis
#

What could you do in a single eval'd code block?

karmic silo
#

im not sure if they work at all without the app though so it might be pointless

outer oasis
#

It does have bs4 already

#

If that's the kinda thing you're looking for

cold island
#

So I just had a big brain idea

#

It can then respond with an ephemeral message

#

No one can mix up the command

#

And the bot doesn't need to auto-delete messages

atomic ivy
#

nice idea.

honest lintel
#

it's kinda weird to see general have 0 activity. maybe it's because of the time in the most common time zones in this server? But I doubt that.

atomic ivy
vale ibex
#

Basically Yea, once that has merged, it will fix your ci

outer oasis
#

What're you waiting on?

#

Just reviews?

vale ibex
#

Reviews

fossil veldt
# vale ibex Reviews

Wait I'm confused, why did we need the user pip installs anyways instead of venv? Was it a caching issue?

vale ibex
#

it was more that we didn't need a venv, since it's a one off image

fossil veldt
#

Also if bot#2268 is switching to venvs shouldn't that fix the issue related to poetry 1.2? But it's also pinning it back to 1.1.15?

dusky shoreBOT
vale ibex
fossil veldt
#

Ah okay, but theoretically it would work for 1.2 now?

vale ibex
#

Yea

fossil veldt
# vale ibex Yea

So currently lint-test.yml has also been changed to use poetry 1.1.* via HassanAbouelela/actions/setup-python@setup-python_v1.2.1?

vale ibex
#

Yea, that pins it

fossil veldt
# vale ibex Yea, that pins it

can we disable the lancebot fuzzy matcher for pygen? Some people were spamming it just now, it's bound to happen again

#

not that it's always malicious but when one person accidentally invokes it everyone goes 'hey look broken thing' and everyone tries it

#

related to sir-lancebot#1090

dusky shoreBOT
vale ibex
fossil veldt
gritty wind
#

The reason it’s not approved was because it’s a bug without a clear resolution pass, that’s probably going to require discussion to figure something out

#

Following the philosophy of organization, I thought it shouldn’t be approved till we know what we actually want

#

No one’s looked into it because people are busy, and it’s not a critical thing

static canyon
#

I mean the solution is pretty easy. Just don't call self.on_command_error.

Imo we should also move the util to botcore since both bot and lance use it, but ig that's not necessary

olive cloak
#

am i understanding correctly that an issue should be opened before PR'ing?

cold island
#

That's the best way to go yes

#

Gives us a chance to look into the proposed change before you put work into changing the code

olive cloak
#

thanks

fading galleon
gritty wind
#

It was proposed before, but it’s not something we want to do in terms of implementation or behavior. It’s hard to implement because the onus is on snekbox to figure out when input is required, communicate back with the bot and the user, and manage the resource and time limits, or parse user code (which is also not easy). In terms of behavior, it’s not something we consider important. Why do you need input instead of just putting in whatever you actually want to run in your program

#

(If you really need it, you can write directly to stdin)

karmic silo
celest charm
#

these didyoumeans are really annoying!

#

is there a way to disable them if the message starts with ..?

static canyon
dusky shoreBOT
static canyon
#

It's not gotten approved but I'm planning to fix it as soon as it does

#

Apparently it's not being considered critical atm though & the core devs are rather busy

celest charm
#

ah

cold island
#

Approval to fix the bug? sure, I think it's indisputable that this is a bug

static canyon
static canyon
cold island
#
  • What util
  • Why does it call self.on_command_error in the first place
#

And let's fix the issue on lance first, we can discuss moving it to botcore separately

static canyon
#

The util that tries to get similar commands

#

Part of that util triggers on_command_error, but it shouldn't

#

I described it all in a comment on the issue

cold island
#

How will you check whether it can be run instead?

static canyon
cold island
#

So before 1064 it would raise an error for not being able to run the command, and then suggest it?

#

And the only thing that changed now is that it does it multiple times

static canyon
#

It doesn't suggest it

#

It just raises & sends the error to Discord

#

It doesn't tell you what the command was

cold island
#

Interesting that it didn't come up before, probably because staff/mods don't get these

static canyon
#

Now there's a continue, so it does it for all matching commands (including subcommands iirc)

#

The error message also self-deletes after so many (I think 3) seconds so realistically only the invoker would see it

#

And if as you say staff/mods don't get them, then that's another thing

#

All contributors to it not being noticed

cold island
#

Anyway that looks like a good solution as far as I can see so I say go for it

static canyon
cold island
#

Do you need to explicitly pass?

static canyon
#

If it'd otherwise be a blank except body then yes

cold island
#

Isn't there a log or something in there

static canyon
#

But just remembered there's a continue there, so no need for pass

cold island
#

Yeah that too

static canyon
#

(also a log, yeah)

#

So it's just a case of removing that one line, cool

cold island
#

Should be, we should test that doesn't mess things up

static canyon
#

Should I also fix the typehint that 1064 did? I.e. Optional[list] --> list (it's always provided, just is sometimes empty)

#
def get_command_suggestions(
        all_commands: list[str], query: str, *, cutoff: int = 60, limit: int = 3
) -> Optional[list]:
    """Get similar command names."""
    results = process.extract(query, all_commands, score_cutoff=cutoff, limit=limit)
    return [result[0] for result in results]```the return type for this
cold island
#

Yeah

#

Shouldn't be a bare list either

static canyon
#

Yep

#

Cool

#

Was... this not how you run tests?```
PS C:\Users\tizzy\sir-lancebot> poetry run task test
could not find task "test"
PS C:\Users\tizzy\sir-lancebot> poetry run task tests
could not find task "tests"

vale ibex
#

no tests in lance

static canyon
#

Right

#

Completely forgot lmao

vale ibex
#

hah no worries

#

CI does a "test"

#

it just checks it can import all the exts

static canyon
#

Also forgot I can't access my GH account right now because I don't have my standard phone number since I'm abroad

#

So I guess the PR will be tomorrow/day after

vale ibex
#

Sure

static canyon
#

Can someone please note on 1090 that it's been approved by @cold island and that I've implemented the fix

#

(sir-lancebot#1090)

dusky shoreBOT
fading galleon
#

Whats the status of bot#2263 I added a pr for it, when will it be merged?

dusky shoreBOT
clever wraith
#

Hey folks,

Can I get some reviews on bot#2261 and site#770 please ?
I know wookie is supposed to review them, but they appear to be busy with other things so I thought maybe someone else could ?

stable mountainBOT
#
It has arrived!

Here's your reminder: review if not already merged
[Jump back to when you created the reminder](#dev-contrib message)

molten perch
#

Hey! I have a very simple PR, that needs one more review, I'd appreciate if someone took a look at it.
sir-robin#60

static canyon
#

RE sir-lancebot#1062

For the part about adding interactivity (react with ❌ to delete etc.) how exactly should this be implemented?

I'm thinking the bot adds the reactions itself, and then a wait_for (potentially in a loop if there's multiple interaction options) will trigger when the user presses one. Maybe even buttons, but I imagine reactions are better here due to the size of buttons.

dusky shoreBOT
static canyon
#

.help

static canyon
cold island
#

yeah, it uses wait_for iirc

static canyon
#

Cool

#
with contextlib.suppress(NotFound):
    try:
        _, new_message = await self.bot.wait_for(
            'message_edit',
            check=_message_edit_predicate,
            timeout=REDO_TIMEOUT
        )
        await ctx.message.add_reaction(REDO_EMOJI)

        await self.bot.wait_for(
            'reaction_add',
            check=_reaction_add_predicate,
            timeout=10
        )

        await ctx.message.clear_reaction(REDO_EMOJI)
        with contextlib.suppress(HTTPException):
            await response.delete()

    except asyncio.TimeoutError:
        # One of the `wait_for` timed out, so abort 
        await ctx.message.clear_reaction(REDO_EMOJI)
        return None

    else:
        # Both `wait_for` triggered, so return the new content to be re-run
        return new_message.content

return None```Where does the bottom `return None` ever get reached? I'm thinking it's only when `await ctx.message.clear_reaction(REDO_EMOJI)` fails due to the emoji not having been added (i.e. when the first `wait_for` fails)
vale ibex
#

it'll be whenever NotFound is raised

#

since it will exit the suppress block

static canyon
#

Right

vale ibex
#

so it could be for that clear reaction, or even for the add reaction

static canyon
#

So also add_reaction

#

Yeah

#
async def continue_job(ctx: Context, response: Message) -> Optional[str]:
    """
    Check if the job should be rerun.

    For a job to be rerun, the user must edit their message within `REDO_TIMEOUT` seconds,
    and then react with the `REDO_EMOJI` within 10 seconds.
    """
    # Correct message and content did actually change (e.g. wasn't a pin status udpate)
    _message_edit_predicate = lambda old, new: new.id == ctx.message.id and new.content != old.content

    _reaction_add_predicate = lambda reaction, user: all((
        user.id == ctx.author.id,  # correct user
        str(reaction) == REDO_EMOJI,  # correct emoji
        reaction.message.id == ctx.message.id  # correct message
    ))

    with contextlib.suppress(NotFound):
        try:
            _, new_message = await self.bot.wait_for(
                'message_edit',
                check=_message_edit_predicate,
                timeout=REDO_TIMEOUT
            )
            await ctx.message.add_reaction(REDO_EMOJI)

            await self.bot.wait_for(
                'reaction_add',
                check=_reaction_add_predicate,
                timeout=10
            )

            await ctx.message.clear_reaction(REDO_EMOJI)
            with contextlib.suppress(HTTPException):
                await response.delete()

        except asyncio.TimeoutError:
            # One of the `wait_for` timed out, so abort
            await ctx.message.clear_reaction(REDO_EMOJI)
            return None

        else:
            # Both `wait_for` triggered, so return the new content to be re-run
            return new_message.content

    return None  # triggered whenever a `NotFound` was raised

```does this look good?
#

I do think the function name should be changed, but not sure what to

#

Maybe rerun_job

#

Or check_rerun_job/maybe_rerun_job since it's not guaranteed to rerun and the function doesn't do the rerunning itself

cold island
#

Maybe you can take inspiration from the structure in eval

static canyon
#

Yeah, I have

#

This is copy-paste from eval, then adjusted

cold island
#

!src eval

stable mountainBOT
#
Command: eval

Run Python code and get the results.

Source Code
static canyon
#

I've also added the comments for clarity

cold island
#

out of the options above, adding maybe is my preference

static canyon
#

I'm thinking check_rerun_job since the docstring is literally "Check if the job should be rerun."

#

And I feel like maybe_rerun_job sounds like the function will do the rerunning (which it doesn't)

cold island
#

ah

#

ok

static canyon
#

I think I'm just about ready to PR

#

Is this good for a bot-core docstring?```py
async def check_rerun_job(ctx: Context, response: Message) -> Optional[str]:
"""
Check if the job should be rerun.

For a job to be rerun, the user must edit their message within `REDO_TIMEOUT` seconds,
and then react with the `REDO_EMOJI` within 10 seconds.

Args:
    ctx: The command's context
    response: The job's response message

Returns:
     The content to be rerun, or `None`.
"""```
cold island
#

If this is bot-core then it should be as generic as possible

#

variable duration for editing, maybe also take a callable to process the response

#

Also you should try implementing it in eval to see if what you did covers this use case, since that's why you're writing it in bot-core

#

is this function the only thing you're adding to bot-core, or are there other parts as well?

gritty wind
#

Use double backticks

cold island
#

is that a sphinx thing?

gritty wind
#

Yes, single backticks do different formatting stuff than md

#

Double backticks are the equivalent

fossil veldt
molten perch
#

Much appreciated! 😄

fallen patrol
gritty wind
#

It’s not on pypi

timid sentinel
hoary haven
#

for a second i even saw @stable mountain reply with an embed to the OP saying "did you mean !close?" or something like that

fading galleon
#

I think the previous use of the lock from the channel's id was still being holded by some await statement, possibly in claim_channel(/bot/bot/exts/help_channels/_cog.py) could be something else too like the lock from user's id being holded somewhere(hard to traceback) becuase when you tried to close it, it closed

kindred sun
#

Apologies if this is the wrong place to ask this. I've been referencing the Python bot's testing code in order to learn to setup testing in my own bot, and I noticed a tiny issue. In bot/tests/helpers.py line 320, additional_spec_asyncs features an attribute, redis_ready, that (seems to) no longer exist in Bot or BotBase. I believe it was removed in fc05849. I'm looking to make small contributions since I've never contributed to an open source project before, would this be something worth making an issue for?

vocal prairie
kindred sun
#

😄

#

i'll try to be more clear

vocal prairie
#

nah you were fine, i just didn't read properly

static canyon
#

@timid sentinel re bot#2233 do you mean the command docstring?

static canyon
#

Cool, will do that soon™️

static canyon
stable mountainBOT
#
ROGER THAT

Your reminder will arrive on <t:1663001978:F>!

timid sentinel
clever wraith
#

@timid sentinel would you mind having a look on bot#2261 again please?
Mark has suggested that we'd allow the rule numbers and keywords to be sent in any orders but also lookup based on multiple keywords and just one.
I thought that it wouldn't really matter after all so I changed it.
Thank you!

dusky shoreBOT
kindred sun
gritty wind
#

Tbh, the testing setup for bot is not great

#

Testing discord.py is already a terrible process, so most contributors struggle with the unittests

#

We don’t pay too much attention tests, we just keep them passing

#

What is there is fine, nothing wrong with it, but it probably shouldn’t be your reference

kindred sun
#

I see. I've been trying to find a way to add tests for my own bot projects and Mocks seem to be the most sane option. Never used them before so I was looking to see how other discord bot projects used them.

#

Discord bots make up the bulk of my "portfolio" projects I show to employers, so it feels wrong to not have any sort of testing.

stable mountainBOT
timid sentinel
#

Wasted a bunch of time looking into that 😑

timid sentinel
kindred sun
timid sentinel
#

Was literally about to send a message here about how I had traced through the logs and code and was convinced what was happening was impossible and made no sense at all, then figured I should just double check...

#

Made the rookie mistake of entertaining the idea that there could be a bug in our code

hoary haven
#

lmaooo

#

very obvious now that i look at it now

#

surwei meow3c

#

so what was that log about notify_session_participants and something being locked?

austere hornet
#

it's not a bug, it's a feature

fading galleon
# stable mountain

I should have also checked that earlier, spent a lot of time on my test server to reproduce it and understand the lock code

cursive relic
#

Where do the results of .http_status come from?

atomic ivy
#

.src http_status

dusky shoreBOT
#
Command: http_status

Choose a cat or dog randomly for the given status code.

Source Code
stable mountainBOT
#

bot/exts/fun/status_codes.py lines 8 to 9

HTTP_DOG_URL = "https://httpstatusdogs.com/img/{code}.jpg"
HTTP_CAT_URL = "https://http.cat/{code}.jpg"```
cursive relic
#

Oh I forgot the .src command.. thank you!

stable mountainBOT
wind ruin
#

not sure if there was any discussion about it before but
now that python 3.11 rc2 is out, should snekbox be updated to use it or just ignore that version?

atomic ivy
#

I thought about it, but seeing as how there are not going to be any changes included other than bug fixes which have open PRs now till release, I thought there's no point

gritty wind
#

Bumping doesn’t cost us anything, feel free to PR it (to the correct branch) if you like

#

It just might take a few days to build and deploy since we didn’t finish the CI for it

static canyon
stable mountainBOT
#
Aye aye, cap'n!

Your reminder will arrive on <t:1663146007:F>!

stable mountainBOT
static canyon
#

Is there a reason that the docstring of the remind edit command includes that of remind edit duration? Surely the help for a subcommand shouldn't be included in the parent? If you want to know how the subcommand works then you can invoke help on the subcommand -- or even press the button for the subcommand since we have that

#

!help remind edit

stable mountainBOT
#
Command Help

!remind edit
Can also use: remind change, remind modify

*Commands for modifying your current reminders.

The expiration duration supports the following symbols for each unit of time: - years: Y, y, year, years - months: m, month, months - weeks: w, W, week, weeks - days: d, D, day, days - hours: H, h, hour, hours - minutes: M, minute, minutes - seconds: S, s, second, seconds

For example, to edit a reminder to expire in 3 days and 1 minute, you can do !remind edit duration 1234 3d1M.*

Subcommands:

!remind edit content <id_> <content>
Edit one of your reminder's content.
!remind edit duration <id_> <expiration>
Edit one of your reminder's expiration.
!remind edit mentions <id_> [mentions]...
Edit one of your reminder's mentions.

static canyon
#

I'm thinking of just removing it as part of my current PR, since it's already in the duration subcommand

mortal whale
#

1

outer oasis
#

So... I tried to rip off @dusky shore, but I broke it.
I stole this:

for ext in walk_extensions():
  bot.load_extension(ext)

But it gives me this:
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited bot.load_extension(ext)
How/when/where do these get awaited?

cold island
#

Where these are synchronous methods

outer oasis
cold island
#

The Python bot

glossy berry
#

Could someone look at my PR and give me an idea of why linting & tests is failing. I only changed one line of code and I'm a bit confused now.

gritty wind
#

Due to a recent change in our dependency manager, our CI is broken temporarily

static canyon
#

What changelog version should a PR to botcore have currently? The next one is 8.3.0, but there's already a PR with that version so should I go latest that isn't taken by a pre-exisiting PR?

gritty wind
#

If you’re coordinating with someone to merge PRs in a certain order, sure

#

Otherwise no just bump as you need from main

#

We follow semver strictly

static canyon
gritty wind
#

Yeah

static canyon
#

Aight

gritty wind
#

I don’t think you’ll pass linting

#

Also please use two backticks for the docstring

#

Single backtick in Sphinx is a different thing than markdown’s

static canyon
#

Ah yeah

#

I forgot about that

#

Should be good now

gritty wind
#

I don’t understand if you want an actual review or not

static canyon
#

I mean you can, but I've not tested it yet so things might end up changing slightly to fix bugs with it

kindred sun
#

@timid sentinel hey do I need to do anything else to get bot#2275 reviewed?

grand holly
#

!contribuute

stable mountainBOT
#

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

  1. Read our contribution guide
  2. Chat with us in #dev-contrib if you're ready to jump in or have any questions
  3. Open an issue or ask to be assigned to an issue to work on
grand holly
#

Hey anyone here

#

I would like to be assigned to this issue
Add number guessing game #1082

#

[lancebot]#1082

#

it's for the lancelotbot

#

Or I can add a cellular automaton generator to the bot

outer oasis
#

sir-lancebot#1082

dusky shoreBOT
grand holly
#

is there anything to do before I clone it and pull request?

outer oasis
#

It's still not approved - so - get a core dev to approve it
(of which I am not)

grand holly
#

I already have the code

#

and it's functional on a another bot I made

outer oasis
#

Go ahead and make an issue for it
You can technically go ahead and make PRs too - there's just no guarantees if they're not approved

grand holly
clever wraith
#

Hello folks,
I'm having a look at our _create_redis_session function in bot.__main__.py and i saw that the type hints are off.

async def _create_redis_session() -> RedisSession:
    """Create and connect to a redis session."""
    redis_session = RedisSession(
        host=constants.Redis.host,
        port=constants.Redis.port,
        password=constants.Redis.password,
        max_connections=20,
        use_fakeredis=constants.Redis.use_fakeredis,
        global_namespace="bot",
        decode_responses=True,
    )
    try:
        return await redis_session.connect()
    except RedisError as e:
        raise StartupError(e)

I'm saying they're off because the connect call returns None.
I know that this isn't that critical, but I'm also guessing it isn't intentional and consistent, right ?

#

Shouldn't we instead star the connection then return the redis_session ?

atomic ivy
#

the RedisSession.connect method does return self

clever wraith
#

Well, I don't see that.
Maybe my packages are outdated

clever wraith
#

I'll run the command to update them & check again

timid sentinel
clever wraith
#

Did I do it wrong ?

fossil veldt
#

@static canyon I'm looking at your pr for lance command suggests, not sure if it's fully within scope but would you want to add an exclusion for commands beginning with multiple (.) to not report a command error at all? It's a pretty common issue and was part of the original issue post

clever wraith
timid sentinel
clever wraith
#

And in the worst case, I can make a new PR & cherry-pick my commits since there aren't so many, what do you think ?

static canyon
#

I don't see why we need to specifically address that anyway

#

It just means if you do ...help it'll recommend help since ..help and help are seen as close enough

#

Is that so bad?

#

(The thing of having multiple responses is nothing to do with the multi-prefix, if that's what you were referring to by "it's a pretty common issue")

timid sentinel
# clever wraith Maybe by rebasing ? It shouldn't conflict with was is currently there

I'll quickly try the solution mentioned here, if it doesn't work you could give rebasing a go, idk https://stackoverflow.com/questions/16306012/github-pull-request-showing-commits-that-are-already-in-target-branch

static canyon
#

@stable mountain help

#

Pretty sure the bot is ded

#

Ah, it's restarting nvm

outer oasis
gritty wind
clever wraith
# timid sentinel seemd to work

Yep !
I'll leave you to have a look then.
And maybe we should discuss how we should display the keywords for each rule, and maybe how many keywords per rule are we having now and how many could we have in the future ?

fossil veldt
#

is our CI broken again?

#

why is the check failing on that

static canyon
#

Yeah, there's a PR for it iirc

#

Hmm maybe not actually

#

This is what's failing:

stable mountainBOT
#

.github/workflows/lint.yaml lines 73 to 78

# Install our dependencies if we did not restore a dependency cache
- name: Install dependencies using poetry
  if: steps.python_cache.outputs.cache-hit != 'true'
  run: |
    pip install poetry
    poetry install --no-interaction --no-ansi```
static canyon
#

Not sure why

#

@gritty wind @vale ibex hello, CI seems to be broken on lancebot. Is this a known thing? (sir-lancebot#1096 and sir-lancebot#1097)

gritty wind
#

Yes it’s a regression in poetry 1.2 that’s affected all our projects

#

We’re rolling out fixes as quickly as we can, but we’re limited by a lack of reviewers

#

So far bot is fixed

#

We’ll get them all eventually

static canyon
#

Cool 👍

static canyon
#

And thanks for the review 👍

cold island
#

Considering the importance, if both you and Chris approve it it's enough for me

static canyon
#

@timid sentinel Fyi I've addressed your review on bot#2232, thanks!

timid sentinel
#

Nice, looks good

clever wraith
#

@timid sentinel All the changes should be in place for bot#2261.
I've tested it against the cases you've mentioned in your last comment & it works accordingly.
However, what do you think about making the command return the matched rules and we add a test for it ?

Have a look whenever you can, thanks !

dusky shoreBOT
fossil veldt
#

bot#2278 is a pretty simple bug and fix if someone wants to approve it

dusky shoreBOT
timid sentinel
#

done 👍

static canyon
fossil veldt
static canyon
#

I'll leave it to you 👍

vale ibex
#

@timid sentinel I don't mind removing that fwiw

#

it was just copy + paste

#

we might use it in future shrugR

timid sentinel
vale ibex
#

I've been adding it to all the bots 😅

timid sentinel
clever wraith
brazen charm
static canyon
brazen charm
#

I don't think netlify is involved there

vale ibex
#

if you delete docs/build and docs/output you should get it locally

#

not sure how it deals with invalidating the build cache

brazen charm
#

didn't get anything when I cleared the build and output

vale ibex
#

I got ```
Warning, treated as error:
C:\Users\chris\src\bot-core\botcore\utils\cooldown.py:docstring of botcore.utils.cooldown.block_duplicate_invocations:8:py:class reference target not found: botcore.utils.cooldown.ParamSpec

brazen charm
#

got it with a recreated environment, not sure what was going on

vale ibex
#

maybe needs a poetry install --sync?

#

to remove dangling deps

clever wraith
timid sentinel
#

So don't worry about it

clever wraith
#

Alright, all good then

#

I'm curious @timid sentinel, how would people know that they can now use keywords to search for rules ?

#

Aside from watching people who know about it using it

#

Idk 🤷‍♂️

timid sentinel
#

That will let people know they can use keywords, although doesn't help so much with knowing what keywords they can use :P

clever wraith
timid sentinel
#

Yeah, probably best for a follow up PR

timid sentinel
#

Thanks @vale ibex lemon_swag

outer oasis
#

Thank you for writing all of them

vale ibex
#

lol

vale ibex
#

@timid sentinel can you sanity check me?

#

Reviewing sir-lancebot#1097

dusky shoreBOT
vale ibex
#

The url key on the original object doesn't seem to be documented on giphy's api

#

I've tested locally and it's returned by the API

#

So I'm not sure if this is a mistake on giphy's part, or if we're using an undocumented key that's likely to cause issues again in future

#

I might suggest changing to data["data"]["images"]["downsized"]["url"]

#

as that's documented

#

and also guarantees the image is <2MB

timid sentinel
#

Ah yeah, your suggestion sounds good, similar to what I suggested a while ago when I looked into it (https://github.com/python-discord/sir-lancebot/issues/1050#issuecomment-1116368854).

I do wonder how they came up with what's in the PR though, maybe just from looking at the API response?

GitHub

Sentry Issue: SIR-LANCEBOT-83 KeyError: 'image_url' File "discord/ext/commands/core.py", line 167, in wrapped ret = await coro(*args, **kwargs) File "bot/...

vale ibex
#

possibly

#

or giphy changes it's api (and docs) frequently

tawdry vapor
#

@vale ibex @gritty wind What's the reason for using the Poetry installer in the Dockerfile? I fail to see what benefits isolating Poetry itself has when it's going to be the only package installed outside of a venv.

gritty wind
#

Yeah I don’t mind either way, it’s just what was in the source we copied from

#

Since we’re using the base image, it doesn’t really matter

tawdry vapor
#

Hmm okay. I will PR a change then. Would make the Dockerfile simpler and avoid installing curl

gritty wind
#

👍

tawdry vapor
#

On second though, I think I'll leave it alone.

#

Because it's in a separate image now, the manner of installation is a bit opaque

#

And we can't guarantee consumers will not install other packages globally

#

@gritty wind I'm not following how your action configures the cache directories. Can you explain?

#

You're caching ~/.cache/py-user-base, but where is this actually being set as the user base dir?

gritty wind
tawdry vapor
#

For the setup-python action?

gritty wind
#

Yeah

tawdry vapor
#

I did not consider that it would change the default user site.

gritty wind
#

For pip and poetry specifically, the GitHub python action actually mentions those by name

#

Under caching

tawdry vapor
#

I'm not seeing that in its docs

#

But I guess the poetry and pre-commit directories used are the defaults as well?

gritty wind
#

You’re right actually, I can’t find where py-user-base is listed

#

But the other two are listed in their docs for sure

tawdry vapor
#

Are you sure it's actually caching the user base then :D

gritty wind
#

It would emit a warning if a path is missing haha

tawdry vapor
#

Though is there any point in caching the user base if we're no longer doing user installs in CI?

#

Wouldn't you want to cache the poetry venv instead?

#

Or the site-packages inside of that. IDK... venvs are more finicky since they aren't portable

gritty wind
#

I’m not sure if it does, but I figured it shouldn’t hurt

#

But yes I hate the new setup

#

Installing to the system is no longer a supported use case however

tawdry vapor
#

In general I think caching user base was a "weird" thing to do - I don't see anyone else doing that, probably cause it's fragile to some degree. But the reasoning behind that is even if the package is downloaded, there is extra time required to install it. not having to do that can save time.

gritty wind
#

“Not using venvs in an anti-pattern”

tawdry vapor
#

I think the non portability of venvs is mostly with the activation scripts. CI is a controlled environment though. As long as we don't move the venv and cache based on Python version then I think we should be okay?

tawdry vapor
# gritty wind “Not using venvs in an anti-pattern”

I think this justification is bogus but the other reason of not wanting to rely on pip anymore was perfectly reasonable. Though I'm not sure if I'd characterise user installs as too niche to replicate as a Poetry feature.

#

me tuning out packaging bullshit and using requirements.txt

gritty wind
#

I’ve come to understand you ways, science man. And I must say, you’re a genius

timid sentinel
#

If I commit a suggestion from someone does their approval still count (as they'd be co-author, no?)?

vale ibex
#

It's only when some commits to the branch they can't approve

#

Whether that's an entirely new commit or a rebase

gritty wind
#

Did you review your own PR

#

Power move

grand holly
#

Any updates on this?

#

sir-lancebot#1098

dusky shoreBOT
brazen charm
#

I concur with mbrauh there, apart from it making a grid of cell based on some rules, I have no idea what it's doing with the arguments

grand holly
#

the rule-number says which type of automaton happens

#

the position tell where to place the starting cell

brazen charm
#

Explain how it works in the issue then, e.g. how the number relates to what's going to happen

static canyon
#

The bot repo has a CustomLogger class that adds a trace method to prevent linting highlights. I've noticed that sir-lancebot has logging, uses .trace, but gives linting warning because it doesn't have the custom class.

Can we do a PR moving the class to bot-core instead, so that it's accessible by both bots?

vale ibex
#

It's already in botcore

#

Lance just isn't using it yet, until my pr

static canyon
#

Ah right

#

That makes sense

vale ibex
#

It's being bot core that is, my pr didn't change logging

#

Didn't want to double the size of the pr lol

static canyon
#

So bot and lancebot (currently) don't use the bot-core class?

vale ibex
#

Not sure

static canyon
#

It doesn't seem so

vale ibex
#

Should be possibly to check

static canyon
#

Yeah, it's not

#

Just checked

#

Can I open PRs for that?

grand holly
#

here is an example of a generation gif

vale ibex
#

Sure

#

You can open a pr on lance too if you want, just base it off my branch

grand holly
#

this is rule 60, with a single cell in the center

static canyon
#

Can you link your PR please?

vale ibex
#

Not easily, I'm on mobile

static canyon
#

Ah no worries

vale ibex
#

There's only like 4 prs on lance atm

static canyon
#

Yeah, I'll look

grand holly
vale ibex
#

That comment was a response to tizzy, not you

grand holly
vale ibex
#

Ok

static canyon
#

It's the setup(), setup_sentry() and _set_trace_loggers()

clever wraith
brazen charm
vocal prairie
tawdry vapor
#

Yes. Want to create the PR? :)

vocal prairie
#

can't do it now, i'm afraid. i might be able to do it tomorrow evening if someone else doesn't, i don't particularly care.

sacred fossil
#

@static canyon sir-lancebot#1096 fixes the on command error but doesn't address the ...... part as in ......what is still triggering the command suggestion while it shouldn't be since to me it seems like Lance should only trigger if the message matches ^\.[^\.\s]+. Should I open a new issue and reference sir-lancebot#1900?

dusky shoreBOT
static canyon
#

It wasn't in the issue, and so didn't get approved, and so I didn't implement it

#

You can make another issue if you'd like to, and if it's approved I'm happy to implement

sacred fossil
#

Lovely

cold island
wind ruin
#

they seem to support RSS feeds for most things, but we also have to consider how much of it (more specifically, which categories) we would want to keep up with

gritty wind
#

No longer reaches the proper audience
Why? Because they all retired of old age?

#

Mailing lists man

cold island
static canyon
#

@timid sentinel RE bot#2232

Would something like Mentions: <@user> (user#discrim) be good?

timid sentinel
#

yeah that sounds fine

cold island
static canyon
#

There's get_or_fetch and handle_role_change

cold island
#

Hmmmmm

vale ibex
#

its in the messages utils iirc

cold island
#

Ah yeah

#

Why is it there lol

vale ibex
#

obviously when a full release is made we can pin to that version instead

#

re bot-core#88 for context

brazen charm
#

I think a proper release will go out today or tomorrow, if my last contribution there is anything to go by

vale ibex
#

ah alright fair enough, no need to rush then

static canyon
#

Which imo is pointless here because the whole point is we want to display extra information for when the ping doesn't render

#

If the ping doesn't render then people will already see the id

static canyon
static canyon
#

I'm writing a PR where I move the re-run logic of !e into bot-core, and I'm trying to also fix a bug with the logic.

After an edit, the bot just assumes everything after !eval is the code, even though it could be a different command argument (in this case, specifying the python version to use)

#

!eval 3.10 print("hello world")

stable mountainBOT
#

@static canyon :x: Your 3.10 eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     3.10 print("hello world")
003 |          ^^^^^
004 | SyntaxError: invalid syntax
static canyon
#

What's the best way to fix this?

#

My current solution is to have the user specify what args can be changed, and then see what actually changed, and go from there (and return what can be changed if everything went correctly)

tawdry vapor
#

Is it possible to re-parse the message as a command and get it arguments, without actually executing the command again?

#

On second thought, that command may rely on additional parsing within rather than just on d.py

#

So if that's the case, maybe refactor the parsing into a separate function?

static canyon
#

!d discord.ext.commands.Bot.get_context

stable mountainBOT
#

await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Note

In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
static canyon
#

Via that ^

static canyon
#

Which I needed

#

If I had that I'd be set

#

The closest I can get is using ctx.args and pairing to ctx.command.clean_args, but there's no fool-proof matching since first provided arg (given by .args) isn't necessarily the first possible arg (given by .clean_args)

#

As an example of my end goal:```py
@bot.command()
async def greet(ctx, name: str = "World"):
"""Will keep saying hello until the user doesn't edit name anymore."""
print("running")
while True:
response = await ctx.send(f"Hello, {name}!")

    changed_args = await check_rerun_job(ctx, response, args_user_can_change=('name',))
    if not changed_args or "name" not in changed_args:
        break  # user didn't change the name, so stop saying hello```
tawdry vapor
#

I'll look into this later this evening and let you know if I think of a good solution.

static canyon
#

Thanks, appreciate it 😄

cold island
#

Honestly if it's resending the result anyway, we could make it re-run the command on the message

#

Pretty sure there's something in dpy for that

#

The code change will be mostly not having a loop anymore, since if the rerun reaction is pressed, it creates a task to rerun the command and then just ends

tawdry vapor
#

Yeah, I think you're correct.

#

One difference would be that the stats would count every re-eval but that's fine, and we probably should've been doing that already.

static canyon
#

So that's most likely what I'll end up doing

#

Which is annoying considering how close I was to making my way work

#

I'll need to see whether error handling works properly when reinvoking, but I don't see why it wouldn't

cold island
static canyon
#

Good to hear it works for filters

static canyon
#

Apparently bot.get_context will get the parent command, not the subcommand

#

And so when I check to see if the command changed, it says it did (even though it didn't)

#

Now I can just not check the command is the same, but that means it allows you to invoke other commands when editing, which I imagine we don't want

#

Tl;Dr; when using subcommands ctx.command != (await ctx.bot.get_context(ctx.message)).command even though it's the same message being parsed

#

From how I see it, we either let the user edit the message into a different command (meaning e.g. an !eval invocation could become a !ping invocation), or don't let users re-run through edit

#

I don't see a big issue with letting users edit into other commands, other than it's not intended behaviour and can't be done unless the command has the util for re-running

midnight jasper
#

@clever wraith I have a project you can contribute to.

clever wraith
midnight jasper
clever wraith
midnight jasper
clever wraith
#

*not new to python or coding in general

clever wraith
midnight jasper
#

Alr. What’s ur most advanced/complex project

clever wraith
#
#

just bored tbh

#

no longer work on any of them, for clarification

midnight jasper
clever wraith
#

no, i made my own platform for cryptocurrency transactions

#

the simpliest way to explain what i made:
a framework for verifying, sending, and notifying if a transaction has been complete

austere hornet
#

@clever wraith @midnight jasper this channel is not for discussing projects other than the ones here on PyDis. You should move your conversation to one of the off-topic channels

#

!ot

stable mountainBOT
clever wraith
#

my bad

#

want to go dms?

midnight jasper
#

Maybe it was jsut to contribute to pydis projects?

#

Idk

clever wraith
#

ye

austere hornet
cold island
#

If you run the command from the ctx it should just work

static canyon
#

We don't have to do that, but it seems odd to allow behaviour that isn't a feature (i.e. you can't edit any command into a different command)

cold island
#

Hmmm right

static canyon
cold island
#

In the args*

static canyon
#

Yeah

#

It doesn't work unfortunately

#

Because ctx.command is a Group, which doesn't have .args

#

It presumably has something to realise there's a subcommand though, so maybe I can find that

cold island
#

Ctx.args

static canyon
cold island
#

Weird

static canyon
#

Gonna delve into the source code and see if I can find anything

stable mountainBOT
#

discord/ext/commands/core.py lines 1619 to 1632

ctx.invoked_subcommand = None
ctx.subcommand_passed = None
early_invoke = not self.invoke_without_command
if early_invoke:
    await self.prepare(ctx)

view = ctx.view
previous = view.index
view.skip_ws()
trigger = view.get_word()

if trigger:
    ctx.subcommand_passed = trigger
    ctx.invoked_subcommand = self.all_commands.get(trigger, None)```
cold island
#

What is that get_word

#

How does it get the word

static canyon
#

I think I've got it

#

I just need to a recursion support so sub-subcommands, sub-sub-subcommands, etc. work

#

It's looking good

vale ibex
#

oh hey, sir-lancebot#1092 is looking mighty fine to review Eyes

dusky shoreBOT
static canyon
#

I can probably figure out an iterative approach (maybe)

#

Work all of the commands, and see if any match

#
new_ctx = await ctx.bot.get_context(ctx.message)
if new_ctx.command is ctx.command:
    await new_ctx.command.invoke(new_ctx)
    return

else:
    print("not same command, so trying to get subcommand")
    if not isinstance(new_ctx.command, Group):
        print("not a group so can't have subcommand")
        return
    group: Group = new_ctx.command

    for command in group.walk_commands():
        if command is ctx.command and new_ctx.message.content.startswith(ctx.prefix+command.qualified_name):
            print("FOUND SUBCOMMAND!")
            await new_ctx.command.invoke(new_ctx)
            return

await ctx.send(":warning: Aborted since you changed the command.")```this *seems* to be working perfectly
#

Nvm

#

If you invoke a parent, you can then edit into a subcommand

summer garden
#

What do we think about adding a !http command to look up what all of the codes mean? I know we have one that is kind of memish with the cat images, but it doesn't offer an explanation

#

The one we have is !http_status

atomic ivy
#

we have those in lancebot, yeah

#

might be nice to have

vale ibex
#

Currently .http_status picks a between cat and dog randomly if not specified

#

We can change that, so that if you don't specify it gives you the "formal" description

#

Adding the .http alias if it isn't there

wild prism
#

ok but can it tell me the correct code to use

vale ibex
#

There's a flowchart for that

#
#

Quite old, so doesn't have the new "hip" codes twitter is trying to make happen, but gets the job done for everything else

#

Oh, I lied, it does

cold island
#

"are you twitter" hahaha

vale ibex
summer garden
vale ibex
summer garden
#

I'll probably do this over the weekend

#

I envision an embed for it with a link in the title to some more concrete info

#

can we just do a big enum for all of the codes?

vale ibex
#

there's one in the http built-in

#

it'll resolve codes to their short meaning

#

and as you say, we can link out for more info

summer garden
vale ibex
#

Yea

summer garden
#

I'm looking and there seems to be some missing. I was looking for 111

vale ibex
#

http.HTTPStatus

summer garden
#

Are there a bunch of different standards?

vale ibex
#

111?

#

don't think that's in the standard

cold island
#

.http 111

#

.http_status 111

dusky shoreBOT
#
Unable to find status floof for 111.
summer garden
#

code 111 came up earlier today so i had it memorized

vale ibex
#

I thought warn codes were deprecated?

#

Yea

#

Was deprecated in rfc9111

summer garden
#

Should they be included for the sites that may still be using them?

vale ibex
#

rfc7234, the one that webconcepts links to, has at the top that it was Obsoleted by: 9111

vale ibex
#

warn codes are in addition to http response codes

#

they're a separate header

static canyon
#

After way, way too many hours, I've finally got a solution for a re-run util. I'll upload it to GitHub tomorrow, but here's the code on a paste: https://paste.pythondiscord.com/jazuvifome
CC @cold island @tawdry vapor

gritty wind
#

Don’t need to hardcode it either, just ask the api for the url, or use a string template

vale ibex
#

mdn good

#

history and stuff could be cool though

#

Maybe both? Not sure what the embed would look like

summer garden
vale ibex
#

Yea, that could be good

#

pushing people to mdn in general is good, it's an amazing resource

static canyon
#

bot-core#137

dusky shoreBOT
sweet glacier
#

Hello guys

#

long time no see

brisk brook
#

Hi 🙂

static canyon
#
  EnvCommandError

  Command C:\Users\tizzy\AppData\Local\pypoetry\Cache\virtualenvs\sir-lancebot-INSnasTY-py3.10\Scripts\pip.exe install --no-deps C:\Users\tizzy\AppData\Local\pypoetry\Cache\artifacts\21\17\d4\ad0f3a8b93e95e364982481a40ecad444c6a57d5fad7c43f74c4283a04\emoji-2.1.0.tar.gz errored with the following return code 1, and output: 
  Processing c:\users\tizzy\appdata\local\pypoetry\cache\artifacts\21\17\d4\ad0f3a8b93e95e364982481a40ecad444c6a57d5fad7c43f74c4283a04\emoji-2.1.0.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'error'
    error: subprocess-exited-with-error
    
    pip subprocess to install build dependencies did not run successfully.
    exit code: 1
    
    [3 lines of output]
    WARNING: Skipping page https://pypi.org/simple/setuptools/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
    ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
    ERROR: No matching distribution found for setuptools>=40.8.0
    [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error
  
  pip subprocess to install build dependencies did not run successfully.
  exit code: 1
  
  See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  

  at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\env.py:1195 in _run
```Trying to redo the env for my local lancebot, and getting this error (failing to get setuptools>=40.8.0). Anyone have any ideas?
#

A manual pip install emoji==2.1.0 seems to have worked 🤷

vale ibex
#

Try poetry cache clear --all

#

WARNING: Skipping page https://pypi.org/simple/setuptools/ because the GET request got Content-Type: Unknown. this seems like the important line

#

Also, what version of poetry are you on?

#

updating might help if you're not on latest

static canyon
#

Or near enough

#

1.1.14 apparently

#

RE sir-lancebot#1079

The code snippets feature uses wait_for_deletion, which currently isn't in lance or bot-core. In fact, bot-core is missing all the message utils, so should I create a PR on bot-core adding these before doing the lance PR?

dusky shoreBOT
vale ibex
#

1.1.16 apparently fixed a caching issue

static canyon
#

What's the best way to update it?

vale ibex
#

Poetry self update is a thing in a recent version, not sure if you have it

#

If not, do the pipe to python thing shown on the website

static canyon
static canyon
# vale ibex Poetry self update is a thing in a recent version, not sure if you have it

The command worked, but now poetry is broken```py
Traceback (most recent call last):
File "C:\Users\tizzy\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\tizzy\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\tizzy\AppData\Roaming\Python\Scripts\poetry.exe_main
.py", line 4, in <module>
ImportError: cannot import name 'main' from 'poetry.console' (C:\Users\tizzy\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console_init
.py)

vale ibex
#

Lol love to see it

#

Run the command on the website

#

Should fix it

static canyon
#

Aight

static canyon
# vale ibex Should fix it

I... don't think it did?```py
PS C:\Users\tizzy\sir-lancebot> poetry --version
PS C:\Users\tizzy\sir-lancebot>

#

I mean the error is gone, but no output

#

Same for things like poetry --help

#

Re-invoking the command on website just says it's already installed

vale ibex
#

That's likely the problem 😅

timid sentinel
#

if anyone has a chance, a second review on bot#2245 would be good

dusky shoreBOT
rapid swallow
#

I'll try to review it tomorrow

vale ibex
vale ibex
#

you're welcome

timid sentinel
vale ibex
#

lol

static canyon
vale ibex
#

If they're easy enough sure

#

Not sure how much they rely on constants

static canyon
#

Don't think they rely on any :)

#

Ah, bot has Emojis, MODERATION_ROLES, NEGATIVE_REPLIES

static canyon
vale ibex
#

depednds on the nature of how they're used

#

they could be hard coded into bot-core if appropriate

#

alternatively, we could do something similar to how the roles get passed into the generic view

static canyon
#

I'll take a look and see

rapid swallow
static canyon
# vale ibex depednds on the nature of how they're used

The only issue I'm having atm is figuring out the botcore equivalent of bot's bot.instance

right_reaction = (
        user != bot.instance.user
        and reaction.message.id == message_id
        and str(reaction.emoji) in allowed_emoji
    )```
vale ibex
#

you could refactor that to be not user.bot

#

slightly different behaviour, but still fine

static canyon
#

Very true

#

Yeah

#
    try:
        try:
            await bot.instance.wait_for('reaction_add', check=check, timeout=timeout)
        except asyncio.TimeoutError:
            await message.clear_reactions()
        else:
            await message.delete()
    except discord.NotFound:
        log.trace(f"wait_for_deletion: message {message.id} deleted prematurely.")
```in `wait_for_deletion`
#

I guess make the util take bot as an arg, with a typehint of commands.Bot?

static canyon
static canyon
#

A PR has been opened! bot-core#141

dusky shoreBOT
cold island
#

hmmmm is there a way to do something when a modal is canceled?

#

I guess there's no response so the modal object wouldn't know...

cold island
#

My code is such a hot pile of garbage, I'm surprised it actually does what I want KEK

clever wraith
#

Hello folks !
I was going through the different issues that we have in our bot project, and I've seen a lot of ones related to filters so it got me intrigued to how it works.

Is there a particular way you'd recommend to have a high level overview of our filtering system & then deep dive ? Or shall I just browse the code ?

cold island
clever wraith
#

But yeah, maybe they should be assigned to you

cold island
#

I'll try to document it properly when I open the PR, but atm it's mostly work that can't really be split

clever wraith
dusky shoreBOT
cold island
#

Ah no, like the issue says it's not blocked by my work

clever wraith
#

Yep, I saw that, but then I when you said "I'm probably handling most of them atm", I thought this could be another thing you're working on & unassigned to you

#

Alright !

cold island
#

Anything that's related to how a message is processed is probably not blocked

#

if you need help to find the relevant code that needs changing lmk

clever wraith
clever wraith
cold island
#

ok, can you comment on the issue?

clever wraith
#

Sure thing

cold island
#

man, it's too easy to click the "assign yourself" button. Assigned you now

clever wraith
#

Ahahahha I saw that, thanks !

cold island
#

Is there an extra step when running migrations on site?

#

found it

#

Is it possible to do it in the container? it says the fs is read-only and I'd rather not set up everything locally

tawdry vapor
cold island
#

Ah there's poetry run task dockermigrations, nice

vale ibex
#

but there was some odd file permission issues on linux that I couldn't fix as I didn't have a linux machine to reproduce the error and investigate

cold island
#

wait, but the PR description says it adds that

#

oh it's still open

#

ok

vale ibex
#

Yea :D

cold island
vale ibex
#

Yea I think that's what we'd want to change the task to

#

it doesn't solve the permission issue though

cold island
vale ibex
#

The PR is in a broken state on linux, yea

#

due to the volume mounts

cold island
#

why specifically linux?

vale ibex
#

File permission differences

cold island
#

hmmm

vale ibex
#

as in, the PR works fine on my windows machine

#

but obviously we want it to work on linux before merging too

cold island
#

alright.. I'll just steal the command from the PR in the meanwhile

vale ibex
#

you'll need to add the compose volume(s) too

vale ibex
#

lol

clever wraith
#

How do I setup the webhook in these cases ?
Am I supposed to create a webhook to the same TextChannel and put its id in the config.yml ?

#

Is that documented somewhere ?

#

Ok found it

#

Found out what to do I mean

clever wraith
tawdry vapor
#

I think the setup guide for the bot has a page that explains how to create a webhook and get its ID.

clever wraith
stable mountainBOT
#

bot/exts/moderation/watchchannels/_watchchannel.py line 131

self.bot.remove_cog(self.__class__.__name__)```
tawdry vapor
#

If it's a coroutine function and it's not awaited then yes it's a bug

clever wraith
#

It's an async function, yes

clever wraith
dusky shoreBOT
clever wraith
#

Hello folks,

I need to make a function that does some string operations on a URL.
This will be used in the watch_rich_embeds filter to fix a bug mentioned in bot#1379

Does it need to live in bot only ? ( If yes, maybe in bot.utils.helpers ? ) or in bot-core ?

dusky shoreBOT
cold island
#

bot is fine

#

Can also just be a helper function in the same module

clever wraith
dusky shoreBOT
grim prairie
#

Wait: where did the announcement about the shortcut tags go for rules?

grim prairie
#

Sheesh. Okay thanks. I thought I was going crazy

#

... or at least more crazy than normal

cold island
summer stone
#

I need help with solving task based on Lagrange theorem

#

Does somebody here know math good enough?

vale ibex
#

The thing is we're mounting .:/app as read only, and then a more specific path as writable

#

So there may be odd interactions there

vale ibex
summer stone
vale ibex
#

No, i mean which issue on our github repo?

summer stone
#

What's github repo?

vale ibex
#

Check the channel description

vale ibex
#
DATABASE_URL=postgres://pysite:pysite@localhost:7777/pysite
METRICITY_DB_URL=postgres://pysite:pysite@localhost:7777/metricity
SECRET_KEY=suitable-for-development-only
STATIC_ROOT=/var/www/static
DEBUG=1
cold island
vale ibex
#

we could mount app as writable, the only reason it isn't is that if the code gets altered by the images somehow, it wouldd be reflected on the host too

#

but I guess that's no different to running on host

vale ibex
#

we could make a new docker compos spec, with the app volume mounted as writable

#

then if you want to run migrations in a fully docker setup, you can use that compose file instead.

cold island
#
Update the compose file and dockerapp file.

The development app from the compose file will now apply migrations on boot and additionally, it will use Django's development server along with the current directory mounted read-only into the container in order to support code reloading, helpful while development.

@last patio a commit you made in 2018. Are you saying that without read-only code reloading won't work?

#

Or were you saying it's mounted to support reloading

vale ibex
#

If it was the case back then, it isn't anymore

last patio
#

mounted read only to prevent permission messes

vale ibex
#

just get a better os kek

last patio
#

thanks

vale ibex
#

I heard rocky was good

last patio
#

docker issues

#

A banned

grand holly
#

bot#1

dusky shoreBOT
grand holly
#

sir-lancebot#1

dusky shoreBOT
grand holly
#

bot[1]

#

bot.1

#

hmm....

gritty wind
#

Could I get some help with pre-commit

vale ibex
#

No

#

go away

#

thanks

gritty wind
#
Flake8...................................................................Failed
- hook id: flake8
- duration: 0.92s
- exit code: 1

C:\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
The command line is too long.

You can probably ignore the poetry warning, I'm just not sure if the The command line is too long. is part of it or not

#

Thanks Chris

#

Flake passes on it's own

#

(This is the most verbose output I could generate)

vale ibex
#

can we bump versions in .pre-commit-config?

gritty wind
#

flake8 = "5.0.4" and pre-commit = "2.20.0"

#

Sure, but pre-commit uses system local flake

#

So it doesn't matter

vale ibex
#

Ah

gritty wind
#

Using local flake is a source of so much pain

#

But specifying all linting dependencies twice is not great either

#

Here's the flake config (unchanged from master):

  - repo: local
    hooks:
      - id: flake8
        name: Flake8
        description: This hook runs flake8 within our project's environment.
        entry: poetry run flake8
        language: system
        types: [python]
        require_serial: true
vale ibex
#

Do we need to bump the version of setuptools?

#

Try setuptools==58.2.0

gritty wind
#

That would be my system setuptools, and I'm pretty sure it's producing a warning because it's too up to date

#

I'm already on Version: 65.4.1

#

Poetry is doing something in a fashion that has been deprecated

#

So I'd need to downgrade to remove that warning

#

Or wait for poetry to fix it

vale ibex
#

Fun

gritty wind
#

I technically could just ignore this since CI does not run flake through pre-commit lemon_clown

#

But then no one would be able to commit to site

#

Which does seem like an oversight

vale ibex
gritty wind
#

Yeah I fixed that locally

vale ibex
#

Ahh right, the error above from locally?

gritty wind
#
site-py3.10C:\Github\PyDis\site>flake8
.\pydis_site\apps\api\tests\test_github_utils.py:31:68: B026 Star-arg unpacking after a keyword argument is strongly discouraged, because it only works when the keyword parameter is declared after all parameters supplied by the unpacked sequence, and this change of ordering can surprise and mislead readers.


site-py3.10C:\Github\PyDis\site>flake8

site-py3.10C:\Github\PyDis\site>
#

Yeah so flake passes now

#

Just pre-commit is broken big-time

vale ibex
#

try remaking the precommit env?

gritty wind
#

Would pre-commit clean do that?

#

Because I'm not sure where it's installed

vale ibex
#

pre-commit uninstall iirc

gritty wind
#

Nah that would just get the hook

vale ibex
#

clean is just for cache

gritty wind
#

Clean seems to have done it

#

As well as deleted all the deps for all the projects on my system

#

Use with caution lol

vale ibex
#

nice

#

nah dude, that's optimisation

gritty wind
#

Anyway, flake is still failing in pre-commit

#

I've pushed all my local changes now, you should be able to see the same things I'm seeing

#

I imagine CI is going to pass, so I've locked down the PR

vale ibex
#

running locally now

gritty wind
#

Uhhh

#

CI failed lol

#

Interestingly, I did get that warning locally, but only on one file

vale ibex
#

I removed require_serial: true from the pre commit config and it ran fine locally

gritty wind
#

I can confirm the same result

#

I also got like 400 deprecation notices, which is interesting

vale ibex
#

I didn't

#

oh

#

in tests

#

yea didn't run those

gritty wind
#

From pre-commit

#

What version of setuptools are you on

vale ibex
#

65.4.1

gritty wind
#

Ah, they only show up if you run with -v

#

verbose

vale ibex
#
🕙 16:05:38 ❯ poetry run task lint -v
Check for merge conflicts................................................Passed
- hook id: check-merge-conflict
- duration: 0.24s
Check Toml...............................................................Passed
- hook id: check-toml
- duration: 0.21s
Check Yaml...............................................................Passed
- hook id: check-yaml
- duration: 0.35s
Fix End of Files.........................................................Passed
- hook id: end-of-file-fixer
- duration: 0.32s
Mixed line ending........................................................Passed
- hook id: mixed-line-ending
- duration: 0.28s
Trim Trailing Whitespace.................................................Passed
- hook id: trailing-whitespace
- duration: 0.3s
check blanket noqa.......................................................Passed
- hook id: python-check-blanket-noqa
- duration: 0.23s
Flake8...................................................................Passed
- hook id: flake8
- duration: 4.84s

Unable to find qualified name for module: manage.py
gritty wind
#

Lol what

#

If you still have it up, could you run tests?

#

These are straight up exceptions not just deprecations

#

And I can't repro

vale ibex
#

yea will do now

#

just need to rebuild everything

#

I cleared my docker system not long ago

gritty wind
#

Ok I found where the deprecations are coming from

#

Weird it didn't pop up when running the project itself, seems django's deprecation warnings only come up when the code is activated

#

I guess that works out for us since we have a 100% coverage requirement on site

#

from datetime import datetime this is going to be the bane of my existance today

vale ibex
#

tests are frozen half way through

#

😅

gritty wind
#

Oh nah they are just kinda slow

#

Kill it if it takes >30 seconds

vale ibex
#

it completed 248 tests without any warnings

#

out of 285

#

rerunning a few times it never got passed that

gritty wind
#

You have to explicitly enable warnings as an env var

#

set PYTHONWARNINGS=error

#

Deprecation warnings are disabled by default

#

It's fine, I've gone ahead and fixed everything

vale ibex
#

cool cool

gritty wind
#

Tests seem to be taking significantly longer now

#

Fuck

#

2 3 4m and going compared to the 18s on main

#

I wonder if it's broken

vale ibex
#

My test suite is consistently getting stuck

gritty wind
#

Ok, perhaps one of the tests is now broken on linux machines, any idea which one?

vale ibex
#

I'm on windows

#

running test suite locally

gritty wind
#

Hm, I'm not getting that

vale ibex
#

when I ctrl+c it's always on File "C:\Users\chris\src\site\pydis_site\apps\redirect\tests.py", line 32, in test_redirects

gritty wind
#

Since I'm running through pycharm

vale ibex
#

I'm running poetry run task test

gritty wind
#

As I've said before, we should delete the redirects app

vale ibex
#

test = "coverage run manage.py test"

gritty wind
#

Ok, this is a good lead, thanks chris

vale ibex
#

The only other line I can see in our code is File "C:\Users\chris\src\site\pydis_site\apps\resources\views\resources.py", line 117, in get

gritty wind
#

How are you still getting the whitenoise error

#

That should be fully suppressed now

#

Ok repro confirmed

#

And now I've confirmed it's only if you run through manage.py

#

It seems to be a django test runner issue, not something in our config/usage specifically. If I bypass all the test stuff in our config and just have it run through manage.py normally, it still freezes

#

Seems to be an issue with django 4.1.*

#

Running it with a debugger, there doesn't seem to be any place where it freezes or takes an unexpected amount of time

#

Although I've only tested one redirect

#

Ok, seems it isn't all redirects, just a specific app most likely

gritty wind
#

Ok, seems that all 10 resource redirects take >12 seconds per resource

#

These are all dynamic

#

Seems like the django render function is responsible

#

Maybe the template is pulling in network resources?

#

Well it would've failed my original test then hmm

#

Ok found it, there does seem to be something here: ```html
<div class="content is-flex is-justify-content-center">
<div class="container is-fullwidth">
{% for resource in resources.values %}
{% include "resources/resource_box.html" %}
{% endfor %}
</div>
</div>

#

This block alone takes 15 seconds per resource

#

That includes ~72 resources in total, the question is why does it start taking so long after 4.1

#

Huh, it takes just as long on django 3

#

Hmm, running now with the same version as CI, it's still really slow

#

Does include make a subrequest of some sort

gritty wind
#

Well actually, if downgrading did not resolve the issue, perhaps that's a red herring

#

I did actually make another change in this PR to the redirects app itself, but I don't see why that would be the cause when it's resources that's failing, not all redirects

#

It was not the cause

#

I reverted all package changes to what's on master, and reverted to python 3.9 which fixed the issue. Now i have the incredibly fun task of again bumping each dep one by one till the issues start again

#

It was sentry

vale ibex
#

sentry is pretty recent in the call chain for my error

gritty wind
#

Well sentry would be present in literally anything that uses the client since it wraps the requests

vale ibex
#

true

gritty wind
#

I have no idea why it slows things down, why specifically for this page, and why on includes

vale ibex
#

So does it all work well fi you bump everything but leave sentry?

gritty wind
#

I'm working on that now

#

Downgrading sentry does indeed resolve the issue

#

Do we just disable sentry in tests

vale ibex
#

currently writing a script that checks every version between 0.20.3 and latest to see where it fails

gritty wind
#

I'd start with 1.9.8 since 1.9.9 does not install in python 3.9

#

Smells of broken release

vale ibex
#

I'm on 3.10

#

everything on latest version

gritty wind
#

Yeah it's definitly 1.9.9

#

1.9.8 works correctly

vale ibex
#

So IG we just pin to 1.9.8 for now

#

Their django update is marked as ongoing

#

so maybe it'll be fixed

gritty wind
#

Why does pip just now show anything if I run pip show sentry-sdk

#

Mildly/highly concerning

#

Ah wasn't in venv

#

Ok agreed

vale ibex
#

poetry run pip

#

ez

gritty wind
#

Literally

#

Ok PR ready

#

Ran 285 tests in 18.672s
Cool

vale ibex
#

Ran 285 tests in 10.943s

#

suck it

gritty wind
#

Homeslice

#

how do you do that

vale ibex
#

still getting whitenoise warning btw

#

lol

gritty wind
#

Stickers don't work for me, so I just assume that's the skill issue sticker

#

Would be a real shame if it loaded and it wasn't that

vale ibex
#

I won't spoil the surprise for you

gritty wind
#

So much so that you might just have to edit your message now before it loads

gritty wind
#

Or the poetry task

vale ibex
gritty wind
#

Oh static preview failed

vale ibex
#

so both?

gritty wind
#

Yeah

#

Ohh yeah the site 500x lol

vale ibex
#

nnice