nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: hikari-py/hikari
Pull request #928 (2021-12-06 19:04:24)

Fix reposition_roles using the wrong route
### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.




JamesTheSergal: Thanks for the help!

Patch:
diff --git a/changes/928.bugfix.md b/changes/928.bugfix.md
new file mode 100644
index 00000000..e8a1817a
--- /dev/null
+++ b/changes/928.bugfix.md
@@ -0,0 +1,1 @@
+Fix reposition_roles using the wrong route.
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index 20806553..9d43eb45 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -2883,7 +2883,7 @@ async def reposition_roles(
         guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
         positions: typing.Mapping[int, snowflakes.SnowflakeishOr[guilds.PartialRole]],
     ) -> None:
-        route = routes.POST_GUILD_ROLES.compile(guild=guild)
+        route = routes.PATCH_GUILD_ROLES.compile(guild=guild)
         body = [{"id": str(int(role)), "position": pos} for pos, role in positions.items()]
         await self._request(route, json=body)
 


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 22098bbf..009e06aa 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -3678,7 +3678,7 @@ async def test_create_role_when_icon_unicode_emoji_specified(self, rest_client):
             await rest_client.create_role(StubModel(123), icon="icon.png", unicode_emoji="\N{OK HAND SIGN}")
 
     async def test_reposition_roles(self, rest_client):
-        expected_route = routes.POST_GUILD_ROLES.compile(guild=123)
+        expected_route = routes.PATCH_GUILD_ROLES.compile(guild=123)
         expected_json = [{"id": "456", "position": 1}, {"id": "789", "position": 2}]
         rest_client._request = mock.AsyncMock()
Repository: hikari-py/hikari
Pull request #995 (2022-02-02 17:27:17)

Fix `$browser` to use the correct format
### Summary
![image](https://user-images.githubusercontent.com/29100934/152205357-34716113-ee2e-4edc-902d-509ebe600192.png)

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.



Patch:
diff --git a/hikari/impl/shard.py b/hikari/impl/shard.py
index a27b4eb8..a4e73332 100644
--- a/hikari/impl/shard.py
+++ b/hikari/impl/shard.py
@@ -688,7 +688,7 @@ async def _identify(self) -> None:
                 "large_threshold": self._large_threshold,
                 "properties": {
                     "$os": f"{platform.system()} {platform.architecture()[0]}",
-                    "$browser": f"aiohttp {aiohttp.__version__}",
+                    "$browser": f"hikari ({about.__version__}, aiohttp {aiohttp.__version__})",
                     "$device": f"hikari {about.__version__}",
                 },
                 "shard": [self._shard_id, self._shard_count],


Test patch:
diff --git a/tests/hikari/impl/test_shard.py b/tests/hikari/impl/test_shard.py
index 41eca84c..63d76424 100644
--- a/tests/hikari/impl/test_shard.py
+++ b/tests/hikari/impl/test_shard.py
@@ -1012,7 +1012,7 @@ async def test__identify(self, client):
                 "large_threshold": 123,
                 "properties": {
                     "$os": "Potato PC ARM64",
-                    "$browser": "aiohttp v0.0.1",
+                    "$browser": "hikari (v1.0.0, aiohttp v0.0.1)",
                     "$device": "hikari v1.0.0",
                 },
                 "shard": [0, 1],
Repository: hikari-py/hikari
Pull request #1021 (2022-02-14 18:03:42)

Add MESSAGE_CONTENT intent
### Summary
Message content intent will be required for verified applications starting April 30th 2022, this change adds them to hikari.
https://support-dev.discord.com/hc/en-us/articles/4404772028055
https://github.com/discord/discord-api-docs/discussions/4510

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [ ] I have made unittests according to the code I have added/modified/deleted.



Patch:
diff --git a/changes/1021.feature.md b/changes/1021.feature.md
new file mode 100644
index 00000000..21ca311c
--- /dev/null
+++ b/changes/1021.feature.md
@@ -0,0 +1,1 @@
+Add MESSAGE_CONTENT intent.
diff --git a/hikari/intents.py b/hikari/intents.py
index 52a04401..085bc709 100644
--- a/hikari/intents.py
+++ b/hikari/intents.py
@@ -288,11 +288,20 @@ class Intents(enums.Flag):
     """
 
     DM_MESSAGE_TYPING = 1 << 14
-    """Subscribes to the following events
+    """Subscribes to the following events:
 
     * `TYPING_START` (in private message channels (non-guild bound) only)
     """
 
+    MESSAGE_CONTENT = 1 << 15
+    """Receive message content for all messages.
+
+    DM's to the bot and messages that mention it are exempt from this.
+
+    !!! warning
+        This intent is privileged, and requires enabling/whitelisting to use.
+    """
+
     # Annoyingly, enums hide classmethods and staticmethods from __dir__ in
     # EnumMeta which means if I make methods to generate these, then stuff
     # will not be documented by pdoc. Alas, my dream of being smart with
@@ -346,7 +355,7 @@ class Intents(enums.Flag):
     ALL_UNPRIVILEGED = ALL_GUILDS_UNPRIVILEGED | ALL_DMS
     """All unprivileged intents."""
 
-    ALL_PRIVILEGED = ALL_GUILDS_PRIVILEGED
+    ALL_PRIVILEGED = ALL_GUILDS_PRIVILEGED | MESSAGE_CONTENT
     """All privileged intents.
 
     !!! warning


Test patch:
diff --git a/tests/hikari/impl/test_shard.py b/tests/hikari/impl/test_shard.py
index 9301be6c..ab5fa4b9 100644
--- a/tests/hikari/impl/test_shard.py
+++ b/tests/hikari/impl/test_shard.py
@@ -1071,7 +1071,7 @@ async def test__identify(self, client):
                     "$device": "hikari v1.0.0",
                 },
                 "shard": [0, 1],
-                "intents": 32767,
+                "intents": 65535,
                 "presence": {"presence": "payload"},
             },
         }
Repository: hikari-py/hikari
Pull request #1069 (2022-03-09 20:20:29)

Disable ws autoclose
### Summary
From testing, this doesnt seem to affect anything at all and just sends payloads that Discord will ignore as well as close unexpectedly on us. Further testing (running constantly for at least 48h) is needed, but I dont see why we should have these enabled.

Would greatly appreciate if someone could try out this PR in their bot and lmk how it goes

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.


CircuitSacul: I tested this by installing directly from your branch. I didn't notice anything different when running the bot (I also double checked the version, which was dev108). I ran it for about 10 minutes, occasionally using commands.
davfsa: > I tested this by installing directly from your branch. I didn't notice anything different when running the bot (I also double checked the version, which was dev108). I ran it for about 10 minutes, occasionally using commands.

Glad to hear, but a more real-word test would be having the bot run for 48h, to make sure it handles all cases correctly (reconnects, unexpected closes, etc).

Appreciate the testing tho!
Jonxslays: Starr is now running on this PR. I'll get back to you. 
davfsa: Ran by @Jonxslays for a while now and there are no changes in reconnect/random disconnects behavior (unfortunately the annoying bug I wanted to fix is still there, but no can do ig)

Marking as ready for review and leaving it up to @FasterSpeeding chose if useful or not

Patch:
diff --git a/hikari/impl/shard.py b/hikari/impl/shard.py
index 6b927df9..406ac586 100644
--- a/hikari/impl/shard.py
+++ b/hikari/impl/shard.py
@@ -279,6 +279,8 @@ async def connect(
                     proxy=proxy_settings.url,
                     proxy_headers=proxy_settings.headers,
                     url=url,
+                    # We manage these ourselves
+                    autoclose=False,
                 )
             )
             assert isinstance(web_socket, cls)


Test patch:
diff --git a/tests/hikari/impl/test_shard.py b/tests/hikari/impl/test_shard.py
index fa75fb07..18d3f1fc 100644
--- a/tests/hikari/impl/test_shard.py
+++ b/tests/hikari/impl/test_shard.py
@@ -354,6 +354,7 @@ def __init__(self):
             proxy=proxy_settings.url,
             proxy_headers=proxy_settings.headers,
             url="https://some.url",
+            autoclose=False,
         )
         mock_client_session.assert_used_once()
         mock_websocket.assert_used_once()
Repository: DesignLiquido/delegua
Pull request #699 (2025-03-01 03:06:30)

#696 Atribuição de dicionário e soma de valores


Patch:
diff --git a/fontes/bibliotecas/primitivas-vetor.ts b/fontes/bibliotecas/primitivas-vetor.ts
index 03c9322f..b2362ed6 100644
--- a/fontes/bibliotecas/primitivas-vetor.ts
+++ b/fontes/bibliotecas/primitivas-vetor.ts
@@ -108,7 +108,10 @@ export default {
         let elemento = vetor.pop();
         return Promise.resolve(elemento);
     },
-    somar: (interpretador: VisitanteComumInterface, vetor: Array<number>): Promise<any> =>
-        Promise.resolve(vetor.reduce((a, b) => a + b)),
+    somar: (interpretador: VisitanteComumInterface, vetor: Array<number | { valor: number }>): Promise<number | { valor: number }> => {
+        return Promise.resolve(
+            vetor.reduce((acc: number, item) => acc + (typeof item === 'number' ? item : item.valor), 0)
+        );
+    },
     tamanho: (interpretador: VisitanteComumInterface, vetor: Array<any>): Promise<any> => Promise.resolve(vetor.length),
 };


Test patch:
diff --git a/testes/interpretador/interpretador.test.ts b/testes/interpretador/interpretador.test.ts
index e6ccb7fc..2229bf3d 100644
--- a/testes/interpretador/interpretador.test.ts
+++ b/testes/interpretador/interpretador.test.ts
@@ -119,6 +119,35 @@ describe('Interpretador', () => {
                     expect(retornoInterpretador.erros).toHaveLength(0);
                 });
 
+                it('Dicionário, atribuição e soma vetor', async () => {
+                    const saidasMensagens = [
+                        '3350'
+                    ];
+
+                    const retornoLexador = lexador.mapear([
+                        'var { estacaoTerraAteColoniaSolis, vilaOmegaAteCidadeNova, luaZetAteBaseDelta } = {',
+                        '"estacaoTerraAteColoniaSolis": 2000,',
+                        '"vilaOmegaAteCidadeNova": 500,',
+                        '"luaZetAteBaseDelta": 850,',
+                        '}',
+                        'var distanciaTotal = [',
+                        'estacaoTerraAteColoniaSolis,',
+                        'vilaOmegaAteCidadeNova,',
+                        'luaZetAteBaseDelta',
+                        '].somar()',
+                        'escreva(distanciaTotal)'
+                    ], -1);
+                    const retornoAvaliadorSintatico = avaliadorSintatico.analisar(retornoLexador, -1);
+
+                    interpretador.funcaoDeRetorno = (saida: any) => {
+                        expect(saidasMensagens.includes(saida)).toBeTruthy();
+                    };
+
+                    const retornoInterpretador = await interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
+
+                    expect(retornoInterpretador.erros).toHaveLength(0);
+                });
+
                 it('Dicionário com valor zero', async () => {
                     const saidasMensagens = [
                         '0'
Repository: DesignLiquido/delegua
Pull request #733 (2025-03-07 14:10:49)

#705 Variável Isto não funciona com interpolação de string
Resolve https://github.com/DesignLiquido/delegua/issues/705


Patch:
diff --git a/fontes/lexador/micro-lexador.ts b/fontes/lexador/micro-lexador.ts
index 211ed0fb..84f26102 100644
--- a/fontes/lexador/micro-lexador.ts
+++ b/fontes/lexador/micro-lexador.ts
@@ -198,6 +198,10 @@ export class MicroLexador {
                 this.analisarTexto("'");
                 this.atual++;
                 break;
+            case '.':
+                this.atual++;
+                this.adicionarSimbolo(tiposDeSimbolos.PONTO);
+                break;
             default:
                 if (this.eDigito(caractere)) this.analisarNumero();
                 else if (this.eAlfabeto(caractere)) this.identificarPalavraChave();


Test patch:
diff --git a/testes/interpretador/interpretador.test.ts b/testes/interpretador/interpretador.test.ts
index 06e2c861..9328c6e5 100644
--- a/testes/interpretador/interpretador.test.ts
+++ b/testes/interpretador/interpretador.test.ts
@@ -244,6 +244,35 @@ describe('Interpretador', () => {
                     expect(retornoInterpretador.erros).toHaveLength(0);
                 });
 
+                it('Interpolação de texto usando \'isto\'', async () => {
+                    const saidasMensagens = [
+                        'Olá, meu nome é Fernando, como posso lhe ajudar?',
+                    ];
+
+                    const retornoLexador = lexador.mapear([
+                        'classe Vendedor {',
+                        'nome: texto',
+                        'construtor(nome) {',
+                        'isto.nome = nome',
+                        '}',
+                        'recebaCliente() {',
+                        'escreva(\'Olá, meu nome é ${isto.nome}, como posso lhe ajudar?\')',
+                        '}',
+                        '}',
+                        'var vendedor = Vendedor(\'Fernando\')',
+                        'vendedor.recebaCliente()'
+                    ], -1);
+                    const retornoAvaliadorSintatico = avaliadorSintatico.analisar(retornoLexador, -1);
+
+                    interpretador.funcaoDeRetorno = (saida: any) => {
+                        expect(saidasMensagens.includes(saida)).toBeTruthy();
+                    };
+
+                    const retornoInterpretador = await interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
+
+                    expect(retornoInterpretador.erros).toHaveLength(0);
+                });
+
                 it('Interpolação de Texto/Função/Expressão', async () => {
                     const saidasMensagens = [
                         'Minha comida favorita é strogonoff',
Repository: DesignLiquido/delegua
Pull request #734 (2025-03-07 19:41:33)

#707 Propriedades de classes com valor zero são resolvidas como nulo
Resolve https://github.com/DesignLiquido/delegua/issues/707


Patch:
diff --git a/fontes/interpretador/interpretador-base.ts b/fontes/interpretador/interpretador-base.ts
index 351dc670..c3f5597c 100644
--- a/fontes/interpretador/interpretador-base.ts
+++ b/fontes/interpretador/interpretador-base.ts
@@ -1530,7 +1530,9 @@ export class InterpretadorBase implements InterpretadorInterface {
         // Outro caso que `instanceof` simplesmente não funciona para casos em Liquido,
         // então testamos também o nome do construtor.
         if (objeto instanceof ObjetoDeleguaClasse || objeto.constructor.name === 'ObjetoDeleguaClasse') {
-            return objeto.obter(expressao.simbolo) || null;
+            const valor = objeto.obter(expressao.simbolo);
+            if (valor === 0) return 0;
+            return valor || null;
         }
 
         // Objeto simples do JavaScript, ou dicionário de Delégua.


Test patch:
diff --git a/testes/interpretador/interpretador.test.ts b/testes/interpretador/interpretador.test.ts
index 9328c6e5..51d7796a 100644
--- a/testes/interpretador/interpretador.test.ts
+++ b/testes/interpretador/interpretador.test.ts
@@ -1911,6 +1911,33 @@ describe('Interpretador', () => {
                     expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
                 });
 
+                it('Classe com propriedade com valor zero', async () => {
+                    const saidasMensagens = ['0'];
+                    const retornoLexador = lexador.mapear(
+                        [
+                            'classe Carteira {',
+                            'saldo: numero',
+                            'construtor() {',
+                            'isto.saldo = 0',
+                            '}',
+                            '}',
+                            'var carteira = Carteira();',
+                            'escreva(carteira.saldo);'
+                        ],
+                        -1
+                    );
+
+                    const retornoAvaliadorSintatico = avaliadorSintatico.analisar(retornoLexador, -1);
+
+                    interpretador.funcaoDeRetorno = (saida: any) => {
+                        expect(saidasMensagens.includes(saida)).toBeTruthy();
+                    };
+
+                    const retornoInterpretador = await interpretador.interpretar(retornoAvaliadorSintatico.declaracoes);
+
+                    expect(retornoInterpretador.erros).toHaveLength(0);
+                });
+
                 it('Super Classe precisa ser uma classe', async () => {
                     const codigo = [
                         'funcao A(data) { }',
Repository: perry-mitchell/webdav-client
Pull request #324 (2022-10-19 04:46:33)

fix: Fix missing leading slash causing extra getDirectoryContents entries
If you don't have a leading slash passed to `getDirectoryContents`, it will cause it to not properly filter out the current directory from the response. This PR fixes that.

This is the actual cause of the issue I was having in the `webdav-fs` repo. https://github.com/perry-mitchell/webdav-fs/issues/84


Patch:
diff --git a/source/operations/directoryContents.ts b/source/operations/directoryContents.ts
index 8988e16..1705403 100644
--- a/source/operations/directoryContents.ts
+++ b/source/operations/directoryContents.ts
@@ -33,7 +33,8 @@ export async function getDirectoryContents(
     const response = await request(requestOptions);
     handleResponseCode(context, response);
     const davResp = await parseXML(response.data as string);
-    let files = getDirectoryFiles(davResp, context.remotePath, remotePath, options.details);
+    const _remotePath = remotePath.startsWith("/") ? remotePath : "/" + remotePath;
+    let files = getDirectoryFiles(davResp, context.remotePath, _remotePath, options.details);
     if (options.glob) {
         files = processGlobFilter(files, options.glob);
     }


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 42938d6..9238dbd 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,6 +1,8 @@
 name: Tests
 
-on: [push, pull_request]
+on:
+  push:
+  pull_request:
 
 jobs:
   specs:
diff --git a/test/node/operations/getDirectoryContents.spec.js b/test/node/operations/getDirectoryContents.spec.js
index 9ac503c..7caaa4e 100644
--- a/test/node/operations/getDirectoryContents.spec.js
+++ b/test/node/operations/getDirectoryContents.spec.js
@@ -85,6 +85,16 @@ describe("getDirectoryContents", function () {
         });
     });
 
+    it("returns correct results when calling without root slash", function () {
+        return this.client.getDirectoryContents("sub1").then(function (contents) {
+            expect(contents).to.have.lengthOf(2);
+            const sub1 = contents.find(item => item.basename === "irrelephant.jpg");
+            expect(sub1).to.be.ok;
+            const sub2 = contents.find(item => item.basename === "ยากจน #1.txt");
+            expect(sub2).to.be.ok;
+        });
+    });
+
     it("returns correct file results for files with special characters", function () {
         return this.client.getDirectoryContents("/sub1").then(function (contents) {
             const sub1 = contents.find(function (item) {
Repository: perry-mitchell/webdav-client
Pull request #325 (2022-11-19 19:32:19)

Pull 324 test
Temporary. See #324


Patch:
diff --git a/source/operations/directoryContents.ts b/source/operations/directoryContents.ts
index 8988e16..1705403 100644
--- a/source/operations/directoryContents.ts
+++ b/source/operations/directoryContents.ts
@@ -33,7 +33,8 @@ export async function getDirectoryContents(
     const response = await request(requestOptions);
     handleResponseCode(context, response);
     const davResp = await parseXML(response.data as string);
-    let files = getDirectoryFiles(davResp, context.remotePath, remotePath, options.details);
+    const _remotePath = remotePath.startsWith("/") ? remotePath : "/" + remotePath;
+    let files = getDirectoryFiles(davResp, context.remotePath, _remotePath, options.details);
     if (options.glob) {
         files = processGlobFilter(files, options.glob);
     }


Test patch:
diff --git a/test/node/operations/getDirectoryContents.spec.js b/test/node/operations/getDirectoryContents.spec.js
index 9ac503c..7caaa4e 100644
--- a/test/node/operations/getDirectoryContents.spec.js
+++ b/test/node/operations/getDirectoryContents.spec.js
@@ -85,6 +85,16 @@ describe("getDirectoryContents", function () {
         });
     });
 
+    it("returns correct results when calling without root slash", function () {
+        return this.client.getDirectoryContents("sub1").then(function (contents) {
+            expect(contents).to.have.lengthOf(2);
+            const sub1 = contents.find(item => item.basename === "irrelephant.jpg");
+            expect(sub1).to.be.ok;
+            const sub2 = contents.find(item => item.basename === "ยากจน #1.txt");
+            expect(sub2).to.be.ok;
+        });
+    });
+
     it("returns correct file results for files with special characters", function () {
         return this.client.getDirectoryContents("/sub1").then(function (contents) {
             const sub1 = contents.find(function (item) {
Repository: keichi/binary-parser
Pull request #193 (2021-11-23 10:02:05)

Fix assert as method definition
It was generating invalid code.


Patch:
diff --git a/lib/binary_parser.ts b/lib/binary_parser.ts
index 85bf579..f4e0e9b 100644
--- a/lib/binary_parser.ts
+++ b/lib/binary_parser.ts
@@ -1011,7 +1011,9 @@ export class Parser {
         );
     }
     ctx.generateError(
-      `"Assertion error: ${varName} is " + ${this.options.assert}`
+      `"Assertion error: ${varName} is " + ${JSON.stringify(
+        this.options.assert.toString()
+      )}`
     );
     ctx.pushCode("}");
   }


Test patch:
diff --git a/test/composite_parser.ts b/test/composite_parser.ts
index dad7892..4378ce9 100644
--- a/test/composite_parser.ts
+++ b/test/composite_parser.ts
@@ -1156,6 +1156,25 @@ function compositeParserTests(
         throws(() => {
           parser2.parse(buffer4);
         });
+
+        const parser3 = new Parser()
+          .int16le("a")
+          .int16le("b")
+          .int16le("c", {
+            assert(this: { a: number; b: number }, x: number | string) {
+              return this.a + this.b === x;
+            },
+          });
+
+        const buffer5 = hexToBuf("d2042e16001b");
+        doesNotThrow(() => {
+          parser3.parse(buffer5);
+        });
+
+        const buffer6 = hexToBuf("2e16001bd204");
+        throws(() => {
+          parser3.parse(buffer6);
+        });
       });
     });