105 Commits

Author SHA1 Message Date
goettner
569840e9e6
[Alias] Aliased commands retain newlines (#4656)
Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
2024-01-08 19:34:48 -05:00
Jakub Kuczys
9c85917dad
Handle exception chaining and groups in Dev's traceback handling (#6178) 2023-06-22 01:42:01 +02:00
Jakub Kuczys
49bf103891
Update the Lavalink version parsing and add tests for it (#6093) 2023-06-21 15:52:00 +02:00
Jakub Kuczys
70ca8ff1f4
Add snippet numbers to filenames in the Dev cog to fix exception formatting (#6135) 2023-05-11 18:27:19 -04:00
Jakub Kuczys
6a53d7dcd5
Add checks submodule to redbot.core.app_commands (#6107) 2023-05-02 10:50:55 -04:00
Flame442
ab8f00ae7b
[Trivia] Fix string interpolation in test errors (#5955)
Co-authored-by: Jakub Kuczys <me@jacken.men>
2023-04-21 01:52:56 +02:00
Jakub Kuczys
f051eae92d
Privatize APIs by renaming or removing them from __all__ (#6021) 2023-04-17 17:44:33 -04:00
Jakub Kuczys
2c4bd38ba1
Show source code in tracebacks sent by Dev cog commands (#5843)
Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
2023-04-15 10:30:19 +01:00
Jakub Kuczys
533f036ed2
Improve performance of pagify() (#5698)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2023-04-13 14:52:54 -04:00
Jakub Kuczys
44e129bc66
Add redbot.core.app_commands namespace (#6006) 2023-03-27 20:49:59 -04:00
Dav
7c7e5edb19
[Modlog]Raise error instead of failing silently on invalid arguments (#5386)
Co-authored-by: Dav <dav@mail.stopdavabuse.de>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2023-03-18 17:31:28 -04:00
Lioness100
a89a27cadf
docs: fix typos (#5989)
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
2023-02-13 21:36:09 -05:00
Vexed
b493103dcb
Improve validation in trivia (#5947)
Co-authored-by: Jakub Kuczys <me@jacken.men>
2023-01-02 05:24:27 +01:00
Jakub Kuczys
519acedf46
Make some dependency changes, support Python 3.10 and 3.11 (#5611)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2022-12-30 03:21:57 +01:00
Flame442
0e97c26b2d
Test implicit subclass type conversion in config defaults/sets (#5874)
Co-authored-by: Jakub Kuczys <me@jacken.men>
2022-12-29 06:50:18 +01:00
Jakub Kuczys
99479342ea
Fix ordering of 3.0.0.dev1 and 3.0.0a1.dev1 versions (#5932) 2022-12-27 17:22:56 -05:00
Jakub Kuczys
43ab6e2ef5
Add missing empty line in error output of Trivia unit test (#5659)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2022-12-27 14:42:20 +01:00
Jakub Kuczys
f7c14b4321
Modernize packaging-related things in Red (#5924) 2022-12-09 18:50:37 +01:00
Jakub Kuczys
51fa3f502e
Remove bordered() utility function (#5692) 2022-11-11 15:37:49 +01:00
Jakub Kuczys
a3de616e4d
Properly handle missing schemas/tables in PostgreSQL driver (#5855) 2022-10-13 13:38:43 +02:00
Jakub Kuczys
f02528378f
discord.py 2.0 update (3d914e08->2.0.1) (#5709) 2022-10-03 16:07:15 +02:00
Jakub Kuczys
ec55622418
Update Downloader's git tests to work with Git 2.36+ (#5690)
There's no need to update RepoManager's code as:
- regex for parsing output about ambiguous refs properly treats the date
  as part of description regardless of ref type
- code for checking if module exists doesn't use the contents of the error message;
  the test only really checks for it to make sure that it triggers the error case
  we're actually testing for. We could instead just remove it too.
2022-04-30 23:28:17 +02:00
jack1142
35f1681dc1
Include tag distance and commit hash in dev versions when possible (#5664)
* Include tag distance and commit hash in dev versions when possible

* Fix test
2022-04-02 19:51:34 -06:00
palmtree5
3254698c78
Update deps, allow Python 3.9, drop Fedora 32 (#5121)
* Update deps + allow Python 3.9

* Add in updates from Jack's branch

* Fix multiple target for cross-reference warnings

* Update a few more Python 3.8 occurrences

* Bump further

* Don't install tox in CodeQL environment

* Bump Python version in docs to 3.9.7

* more bumps

* Add missing pin

* Stop using the deprecated distro.linux_distribution()

* Suppress deprecation warning

* Fix OpenSUSE Leap instructions

* Drop Fedora 32

* Add Python 3.10-dev to CI

* meh

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-09-06 18:43:29 +02:00
Zoë F
ed9bb77eec
Add RelativedeltaConverter and parse_relativedelta (#5000)
* Added years and months to parse_timedelta

* Added new parse_datetimedelta along with classes for relative dates

* Switched datetime as dt to just datetime for clarity

* Changed to returning relativedelta instead of datetime

* Fixed single char typo

* After some digging, removed min and max from relative delta b/c of https://github.com/dateutil/dateutil/issues/350

* Add dateutil to intersphinx mapping

* Change uppercase D in RelativeDeltaConverter to a lowercase D

* Fix cross-references in docstrings

* Add new class and methods to __all__

* Remove get_relativedelta_converter()

* style

* Fix name of parse_relativedelta test

* more style

* Re-export new class and function in `redbot.core.commands`

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-09-06 02:50:21 +02:00
jack1142
6f0a8b11d7
Add test for presence of upper and lower bound on Python version (#5198)
* Add test for presence of upper and lower bound on Python version

* [part 1/3] Test that this works, DO NOT MERGE

* [part 2/3] Test that this works, DO NOT MERGE

* [part 3/3] Revert unwanted changes, NOW YOU CAN MERGE!
2021-09-02 01:52:27 +02:00
Grant LeBlanc
173127e015
[Trivia] Validate custom trivia file upload using schema (#4659)
* Add custom trivia list schema validation and test

* Address review

* Improve error formatting in trivia list test

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2021-08-31 20:44:25 +02:00
jack1142
ef803072fa
Update ambiguous oid parsing to detect candidates on Git 2.31+ (#4897)
* Update ambiguous oid parsing to detect candidates on Git 2.31+

* Update tests
2021-03-24 00:52:52 +01:00
jack1142
e1226c6c88
Update to d.py 1.5.1, explicitly request privileged intents (#4423)
Co-authored-by: Draper <27962761+Drapersniper@users.noreply.github.com>
2020-10-21 19:55:25 +01:00
DevilXD
6e63ed4e60
Use aware objects when storing and reading UTC timestamps (#4017)
* Use aware objects instead of naive ones

* Use aware objects when storing and reading UTC timestamps

* Remove unneeded parentheses

* Fixed naive and aware objects unable to be compared here

* Address feedback

* Fix the newly added `modlog.create_case()` calls

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-08-12 10:46:32 +02:00
jack1142
c673bb0979
Fix the errors related to installed module having invalid commit data (#4086) 2020-08-05 19:35:57 +01:00
jack1142
8c484f86a9
Make bordered() use + for corners if ascii_border=True (#4097) 2020-07-23 12:32:41 +01:00
Toby Harradine
7aff7962f0
Fix creation of IdentifierData in config raw methods (#3829)
* Fix creation of IdentifierData in config

Also adds some new tests regarding partial primary keys.

Resolves #3796.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-05-09 15:11:23 +10:00
TrustyJAID
6f6c536236
[Alias] Create caching to call config less frequently (#3788) 2020-04-27 02:25:41 +02:00
Michael H
00cf395483
Handle deprecations in asyncio (#3509)
* passing loop to certain things was deprecated. additionally, `asyncio.get_event_loop()` is being deprecated

* awesome, checks are functioning as intended

* fun with fixtures

* we can just stop misuing that anyhow

* Update redbot/pytest/downloader.py

Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
2020-02-05 17:16:13 -05:00
Flame442
e776b5ca1a [Admin] Code prettification and bugfixing (#3250)
* Facelift for Admin

* Remove unnecessary converter, reorder existing steps

* Delete admin.py

* Delete __init__.py

* Delete test_admin.py

* Remove one extra unneeded check

* Create 3250.bugfix.1.rst

* Create 3250.bugfix.2.rst

* Create 3250.bugfix.3.rst

* Create 3250.bugfix.4.rst

* Create 3250.misc.1.rst

* Create 3250.misc.2.rst

* Create 3250.misc.3.rst

* Create 3250.breaking.1.rst

* Create 3250.breaking.2.rst

* ...

* I hate black...
2020-01-02 09:11:27 -05:00
Michael H
a80e20067c
do better with loop cleanup (#3245)
* do better with loop cleanup

* changelog

* remove redundant line

* Do this a bit better than the initial pass

* Improve windows support

Make some other things coroutines to work with improved design

* Wish we'd have done this right from the start...

* Update deps surrounding this

 - see bpo-23057
 - neccessary for windows users
 - nice for consistent support channel info / feature availability

* dep issue

* Fix tests

* duplication plugin py version

* actually handle this

* Reconfigure some checks with codeclimate, disable pylint for now

* style

* Is my exasperation showing yet?

* handle some stupid stuff

* meh

* dep changelog
2020-01-01 19:26:32 -05:00
Michael H
dd899c804a
Remove the mongo driver (#3099)
* kills mongo

* changelog

* more refeences to mongo needed to go
2019-11-08 14:48:04 -05:00
jack1142
e2c8b11008 [V3 Downloader] Revision tracking (#2571)
* feat(downloader): Install cog from specific commit in repo (initial commit)

- Repo and Installable have commit property now
- New class inheriting from Installable -
InstalledCog (old one from converters.py removed)
- New Repo.checkout() method, which is also async ctx manager
ref #2527

* fix(downloader): Keep information about repo's branch in config

- This is needed to make sure that repo can go back from detached state in some rare unexpected
cases
- current branch is determined by `git symbolic-ref` now as this command errors for detached
HEAD

* feat(downloader): Update repo without cogs, update single cog

The most important part of issue #2527 has been added here
- `[p]repo update` command added
- new conf format - nested dictionary repo_name->cog_name->cog_json
  installed libraries are now kept in conf too
  - `InstalledCog` renamed to `InstalledModule` - installed libraries use this class
  - `Downloader.installed_libraries()` and `Downloader.installed_modules()` added
  - `Downloader._add_to_installed()` and `Downloader._remove_from_installed()`
    now accept list of modules, of both cogs and libraries
- `[p]cog install` tells about fails of copying cog and installing shared libraries
- `[p]cog update` will truly update only chosen cogs (if provided) or cogs that need update
  - pinned cogs aren't checked
  - before update, repos are updated
  - to determine if update is needed `Repo.get_modified_modules()` is used
- `[p]cog pin` and `[p]cog unpin` commands for pinning/unpinning cogs added
- `Repo.checkout()` allows to choose ctx manager exit's checkout revision
- `Repo.install_cog()` returns `InstalledModule` now and raises CopyingError (maybe breaking?)
- `Repo.install_libraries()` returns 2-tuple of installed and failed libraries (maybe breaking?)
- `RepoManager.get_all_cogs()` added, which returns cogs from all repos
- `RepoManager.repos` property added, which contains tuple of `Repo`

* test(downloader): Repo.current_branch() throws an exception, when branch can't be determined

* style(downloader): rename _add_to_installed to _save_to_installed

This method is used for both adding and updating existing modules in Config

* refactor(downloader): add ctx.typing() for few commands

`[p]cog install` is nested hell, can't wait for moving install logic to separate method

* fix(downloader): refactor and fix `set` usage

* perf(downloader): update commits for ALL checked modules to omit diffs next time

This will also disable running git diff for cogs that have the same commit as the latest one

* style(downloader): few style improvements

- use of mutable object in method definition
- make Repo._get_full_sha1() public method
- too long
line
- don't use len to check if sequence is empty

* feat(downloader): add `[p]cog updateallfromrepos` and `[p]cog updatetoversion` commands

- moved cog update logic into `Downloader._cog_update_logic()` (lack of better name)
  - splitted
whole cog update process into smaller methods
  - might still need some improvements
- added new
methods to `Repo` class:
  - `is_on_branch()` to check if repo is currently checked out to branch

- `is_ancestor()` to check if one commit is ancestor of the other
- fix for
`Downloader._available_updates()` behaviour
broken by commit
5755ab08ba67556b3863e907c6f44d80f4f13d88

* feat(downloader): try to find last commit where module is still present

Enhancements:
- `Installable` now has `repo` attribute containing repo object or `None` if repo is
missing
- `Downloader._install_cogs()` and `Downloader._reinstall_libraries()` are able to install
modules from different commits of repo
- `Repo.checkout()` as ctx manager will now exit to commit
which was active before checking out
- unification of `rev` and `hash` terms:
All function
parameters are explicitly called `hash`, if it can only be commit's full sha1 hash or `rev` if it
can be anything that names a commit object, see
[link](https://git-scm.com/docs/git-rev-parse#_specifying_revisions)
- new
`Repo.get_last_module_occurence()` method, which gets module's Installable from last commit in which
it still occurs

* docs(downloader): Add basic description for `InstalledModule`

* fix(downloader): cog ignored during updates if its commit was missing

After config format update, commit string is empty until update and when such cog was checked and it
wasn't available in repo anymore, it was ignored

* refactor(downloader): Installing cogs from specific rev will pin them

* perf(downloader): Don't checkout when current commit equals target hash

- changes to `Repo.checkout()`:
  - `exit_to_rev` is now keyword only argument
  - added
`force_checkout` to force checkout even if `Repo.commit` value is the same as target hash

* refactor(downloader): Repo._run() stderr is redirected to debug log now

- added two keyword arguments:
  - `valid_exit_codes` which specifies valid exit codes, used to
determine if stderr should be sent as debug or error level in logging
  - `debug_only` which
specifies if stderr can be sent only as debug level in logging

* style(downloader): stop using `set` as arg name in `_load_repos()`

* feat(downloader): pass multiple cogs to `[p]cog (un)pin`

* refactor(downloader): accept module name instead of instance, fix spelling

* style(downloader): few small style changes

* fix(downloader): add type annotations + fixes based on them

- fix wrong type annotations and add a lot of new ones
- add checks for `Installable.repo` being `None`
- fix wrong return type in `Downloader._install_requirements`
- show repo names correctly when updating all repos
- fix error when some requirement fails to install

BREAKING CHANGE:
- type of `Repo.available_modules` is now consistent (always `tuple`)

* tests: use same event loop policy as in Red's code

* enhance(downloader): fully handle ambiguous revisions

* build(deps): add pytest-mock dependency to tests extra

* fix(downloader): minor fixes

* feat(downloader): add tool for editing Downloader's test repo

This script aims to help update the human-readable version of repo
used for git integration tests in ``redbot/tests/downloader_testrepo.export``
by exporting/importing it in/from provided directory.

Note
----
Editing `downloader_git_test_repo.export` file manually is strongly discouraged,
especially editing any part of commit directives as that causes a change in the commit's hash.
Another problem devs could encounter when trying to manually edit that file
are editors that will use CRLF instead of LF for new line character(s) and therefore break it.

I also used `.gitattributes` to prevent autocrlf from breaking testrepo.

Also, if Git ever changes currently used SHA-1 to SHA-256 we will have to
update old hashes with new ones. But it's a small drawback,
when we can have human-readable version of repo.

Known limitations
-----------------
``git fast-export`` exports commits without GPG signs so this script disables it in repo's config.
This also means devs shouldn't use ``--gpg-sign`` flag in ``git commit`` within the test repo.

* tests(downloader): add git tests and test repo for them

Also added Markdown file that is even more clear than export file
on what the test repo contains.
This is manually created but can be automated on later date.

* test(downloader): add more tests related to RepoManager

These tests use expected output that is already guaranteed by git tests.

* chore(CODEOWNERS): add jack1142 to Downloader's folders

I know this doesn't actually give any benefit to people that don't have
write permission to the repo but I saw other big fella devs doing this,
so I think this might be advisable.

* enhance(downloader): allow easy schema updates in future

* enhance(downloader): more typing fixes, add comments for clarity

* feat(downloader): add python and bot version check to update process

follow-up on #2605, this commit fully fixes #1866

* chore(changelog): add towncrier entries

* fix(downloader): use `*args` instead of `commands.Greedy`

* fix(downloader): hot-reload issue - `InstallableType` now inherits from `IntEnum`

There's desync of `InstallableType` class types due to hot-reload
and `IntEnum` allows for equality check between different types

* enhance(downloader): ensure there's no cog with same name installed

should fix #2927

* fix(downloader): last few changes before marking as ready for review
2019-11-07 20:36:16 -05:00
Toby Harradine
d1a46acc9a PostgreSQL driver, tests against DB backends, and general drivers cleanup (#2723)
* PostgreSQL driver and general drivers cleanup

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Make tests pass

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add black --target-version flag in make.bat

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Rewrite postgres driver

Most of the logic is now in PL/pgSQL.

This completely avoids the use of Python f-strings to format identifiers into queries. Although an SQL-injection attack would have been impossible anyway (only the owner would have ever had the ability to do that), using PostgreSQL's format() is more reliable for unusual identifiers. Performance-wise, I'm not sure whether this is an improvement, but I highly doubt that it's worse.

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Reformat

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Fix PostgresDriver.delete_all_data()

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Clean up PL/pgSQL code

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* More PL/pgSQL cleanup

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* PL/pgSQL function optimisations

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Ensure compatibility with PostgreSQL 10 and below

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* More/better docstrings for PG functions

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Fix typo in docstring

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Return correct value on toggle()

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Use composite type for PG function parameters

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Fix JSON driver's Config.clear_all()

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Correct description for Mongo tox recipe

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Fix linting errors

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Update dep specification after merging bumpdeps

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add towncrier entries

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Update from merge

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Mention [postgres] extra in install docs

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Support more connection options and use better defaults

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Actually pass PG env vars in tox

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Replace event trigger with manual DELETE queries

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-08-26 22:02:26 -04:00
DiscordLiz
20091cc10a [ModLog API] Add default casetypes, remove need for a specific auditlog action (#2901)
* I know this needs a changelog entry and docs still

* update tests for new behavior

* update docs, filter; add changelog

* Ready for review

* stop fetching the same Audit logs when the bot is the mod

* I forgot to press save

* fix a comprehension

* Fix AttributeError

* And the other place that happens

* timing fixes
2019-07-27 15:37:29 -04:00
Toby Harradine
af096bc1cc Config locks (#2654)
* Config locks

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add locks for all_XXX

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Remove a word

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add acquire_lock kwarg for value context manager

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Add towncrier entry

Signed-off-by: Toby <tobyharradine@gmail.com>

* Fix issues with `get_custom_lock` and `get_members_lock`

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-07-23 16:50:07 -04:00
jack1142
24ac111782 [V3 Downloader] Allow to specify minimum and maximum bot version in info.json (#2605)
* feat(downloader): add `min_bot_version` and `max_bot_version`

Adds actually working way of specifying minimum and maximum bot version and removes not working
`bot_version`

BREAKING CHANGE: - removal of `bot_version` attribute in `Installable`

* test(downloader): `Installable` tests fix for new bot version attributes

* docs(changelog): added changelog entries for this PR
2019-04-29 12:33:49 -04:00
jack1142
972fbecc94 [V3 Trivia] Make sure that test will use utf-8 encoding (#2565) 2019-04-09 17:03:34 -04:00
Michael H
136e781c7f Kill DataConverter (#2554)
* Kill DataConverter

* remove the tests
2019-04-09 17:01:04 -04:00
Will
0852d1be9f
[V3 Config] Require custom group initialization before usage (#2545)
* Require custom group initialization before usage and write that data to disk

* Style

* add tests

* remove custom info update method from drivers

* clean up remnant

* Turn config objects into a singleton to deal with custom group identifiers

* Fix dumbassery

* Stupid stupid stupid
2019-04-04 21:47:08 -04:00
Seputaes
16614168a7 [Downloader] Install SHARED_LIBRARY requirements (#2384)
SHARED_LIBRARY Installable types did not have the requirements as
defined in info.json automatically installed. This change updates the
installation of libraries to also install their requirements.

Resolves #2381
2019-02-27 16:07:05 +11:00
Toby Harradine
b1066ad58f
Guard module-level creation of Config objects (#2449)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
2019-02-14 15:36:48 +11:00
Twentysix
889fa63aff Sentry removal (#2439)
Resolves #2430.
2019-02-11 11:19:02 +11:00
Michael H
985e7b3c6d swap unsafe yaml.load usage for yaml.safe_load (#2324)
Related to #2323

Recommend additionally adding a step in CI
ensuring use of `yaml.load` is prevented from existing in the code base.
2018-12-13 18:19:27 +01:00