internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Rapptz/discord.py

Issue:
Line 595 in voice_client.py missing a word
### Summary

missing the word "be" in between "must" and "an"

### Reproduction Steps

n/a

### Minimal Reproducible Code

_No response_

### Expected Results

n/a

### Actual Results

n/a

### Intents

n/a

### System Information

n/a

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

didn't know where to report this 😔


Discussion:

Resolving patch:
diff --git a/discord/voice_client.py b/discord/voice_client.py
--- a/discord/voice_client.py
+++ b/discord/voice_client.py
@@ -592,7 +592,7 @@ def play(self, source: AudioSource, *, after: Callable[[Optional[Exception]], An
             raise ClientException('Already playing audio.')
 
         if not isinstance(source, AudioSource):
-            raise TypeError(f'source must an AudioSource not {source.__class__.__name__}')
+            raise TypeError(f'source must be an AudioSource not {source.__class__.__name__}')
 
         if not self.encoder and not source.is_opus():
             self.encoder = opus.Encoder()


Test patch:
Repository: Rapptz/discord.py

Issue:
UnexpectedQuoteError for keyword only args when preceded by optional argument
### Summary

When a keyword only argument contains a single quote character such as " an error if thrown if that argument is preceded by an optional argument.

### Reproduction Steps

Reproduction code below. Here are the commands used to reproduce the bug in command response pairs

`-test1 abc"`
Throws UnexpectedQuoteError

`-test2 abc"`
`This works. abc"`

`-test3 1 abc"`
`This works. 1 abc"`


### Minimal Reproducible Code

```python
from typing import Optional

from discord.ext.commands import Bot

bot = Bot('-')


@bot.event
async def on_ready():
    print('ready')


@bot.command()
async def test1(ctx, optional: Optional[int], *, rest):
    await ctx.send(f'This does not work. {rest}')


@bot.command()
async def test2(ctx, *, rest):
    await ctx.send(f'This works. {rest}')


@bot.command()
async def test3(ctx, required: int, *, rest):
    await ctx.send(f'This works. {required} {rest}')


bot.run('token')
```


### Expected Results

I expected no error to be thrown when calling the test1 command.

### Actual Results

UnexpectedQuoteError was thrown when string contained a quote character.

### Intents

Default intents

### System Information

- Python v3.7.4-final
- discord.py v1.7.3-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.18362


### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

ExpectedClosingQuoteError is also thrown for test1 if the string starts with a quote while it is not thrown for the other two commands.


Discussion:
The bug here is that `Optional` doesn't unwind due to parsing errors. This might end up being a bit tricky to do.

Resolving patch:
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -505,7 +505,14 @@ async def transform(self, ctx, param):
         if consume_rest_is_special:
             argument = view.read_rest().strip()
         else:
-            argument = view.get_quoted_word()
+            try:
+                argument = view.get_quoted_word()
+            except ArgumentParsingError as exc:
+                if self._is_typing_optional(param.annotation):
+                    view.index = previous
+                    return None
+                else:
+                    raise exc
         view.previous = previous
 
         return await run_converters(ctx, converter, argument, param)


Test patch:
Repository: Rapptz/discord.py

Issue:
abc.Connectable.play is wrong
### Summary

I found a typo in the docs "what's new".

### Reproduction Steps

Open [the document](https://github.com/Rapptz/discord.py/blob/d30fea5b0dcba9cd130026b56ec01e78bd788aff/docs/whats_new.rst#:~:text=Allow%20callable%20class%20factories%20to%20be%20used%20in%20%3Ameth%3A%60abc.Connectable.play%60%20(%3Aissue%3A%606478%60)) then you can see the typo.

### Minimal Reproducible Code

_No response_

### Expected Results

`abc.Connectable.play` should be fixed to `abc.Connectable.connect`.

### Actual Results

There is a typo in the docs.

### Intents

unrelated

### System Information

unrelated

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

I found this typo while translating the docs into Japanese.


Discussion:

Resolving patch:
diff --git a/discord/abc.py b/discord/abc.py
--- a/discord/abc.py
+++ b/discord/abc.py
@@ -1686,14 +1686,14 @@ async def connect(
         *,
         timeout: float = 60.0,
         reconnect: bool = True,
-        cls: Callable[[Client, Connectable], T] = VoiceClient,
+        cls: Callable[[Client, Connectable], T] = MISSING,
     ) -> T:
         """|coro|
 
-        Connects to voice and creates a :class:`VoiceClient` to establish
+        Connects to voice and creates a :class:`~discord.VoiceClient` to establish
         your connection to the voice server.
 
-        This requires :attr:`Intents.voice_states`.
+        This requires :attr:`~discord.Intents.voice_states`.
 
         Parameters
         -----------
@@ -1703,7 +1703,7 @@ async def connect(
             Whether the bot should automatically attempt
             a reconnect if a part of the handshake fails
             or the gateway goes down.
-        cls: Type[:class:`VoiceProtocol`]
+        cls: Type[:class:`~discord.VoiceProtocol`]
             A type that subclasses :class:`~discord.VoiceProtocol` to connect with.
             Defaults to :class:`~discord.VoiceClient`.
 
@@ -1729,6 +1729,10 @@ async def connect(
             raise ClientException('Already connected to a voice channel.')
 
         client = state._get_client()
+
+        if cls is MISSING:
+            cls = VoiceClient
+
         voice = cls(client, self)
 
         if not isinstance(voice, VoiceProtocol):


Test patch:
Repository: Rapptz/discord.py

Issue:
Archived threads do not get evicted from Guild.threads cache
### Summary

Thread stays in Guild.threads when it's archived during bot's runtime.

### Reproduction Steps

Check the value of `guild.threads` after each step:
1. Create a public thread.
2. Archive a thread.
3. Check the value of `Guild.threads` and notice that the thread was not evicted from cache

### Minimal Reproducible Code

```python
Here's a few tests and their results:

print(guild.threads)

thread = await channel.create_thread(name="example-thread", type=discord.ChannelType.public_thread)
await asyncio.sleep(0)  # allow the gateway events to come
print(guild.threads)

await thread.edit(archived=True)
await asyncio.sleep(0)  # allow the gateway events to come
print(guild.threads)

await thread.edit(archived=False)
await asyncio.sleep(0)  # allow the gateway events to come
print(guild.threads)

await thread.edit(locked=True)
await asyncio.sleep(0)  # allow the gateway events to come
print(guild.threads)
```

Results:
```
[]
[<Thread id=950038334057644153 name='example-thread' parent=commands owner_id=536260979772882946 locked=False archived=False>]
[<Thread id=950038334057644153 name='example-thread' parent=commands owner_id=536260979772882946 locked=False archived=True>]
[<Thread id=950038334057644153 name='example-thread' parent=commands owner_id=536260979772882946 locked=False archived=False>]
[<Thread id=950038334057644153 name='example-thread' parent=commands owner_id=536260979772882946 locked=True archived=False>]
```


### Expected Results

I expected the thread to be evicted from the cache.

### Actual Results

The thread was not evicted from the cache.

### Intents

discord.Intents.all()

### System Information

λ python -m discord -v
- Python v3.8.10-final
- discord.py v2.0.0-alpha
    - discord.py pkg_resources: v2.0.0a3741+ga909c1ff
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19043

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/discord/state.py b/discord/state.py
--- a/discord/state.py
+++ b/discord/state.py
@@ -857,10 +857,13 @@ def parse_thread_update(self, data: gw.ThreadUpdateEvent) -> None:
         if thread is not None:
             old = copy.copy(thread)
             thread._update(data)
+            if thread.archived:
+                guild._remove_thread(thread)
             self.dispatch('thread_update', old, thread)
         else:
             thread = Thread(guild=guild, state=guild._state, data=data)
-            guild._add_thread(thread)
+            if not thread.archived:
+                guild._add_thread(thread)
             self.dispatch('thread_join', thread)
 
     def parse_thread_delete(self, data: gw.ThreadDeleteEvent) -> None:


Test patch:
Repository: Rapptz/discord.py

Issue:
a typo in the docstring of Client.get_stage_instance
### Summary

I found a typo in the docstring of Client.get_stage_instance

### Reproduction Steps

See [code](https://github.com/Rapptz/discord.py/blob/d22a7fb793331257eebdad696087754659e5c511/discord/client.py#L836) then you can see the typo.

### Minimal Reproducible Code

_No response_

### Expected Results

The returns stage instance **_or_** ``None`` if not found.

### Actual Results

The returns stage instance _**of**_ ``None`` if not found.

### Intents

unrelated

### System Information

unrelated

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:
because it's very small bug, i'll create a PR by myself.

Resolving patch:
diff --git a/discord/client.py b/discord/client.py
--- a/discord/client.py
+++ b/discord/client.py
@@ -833,7 +833,7 @@ def get_stage_instance(self, id: int, /) -> Optional[StageInstance]:
         Returns
         --------
         Optional[:class:`.StageInstance`]
-            The returns stage instance of ``None`` if not found.
+            The stage instance or ``None`` if not found.
         """
         from .channel import StageChannel
 


Test patch:
Repository: Rapptz/discord.py

Issue:
Message.edit ignores `suppress` kwarg
### Summary

When using the keyworded arg suppress in the Message.edit() method then 

### Reproduction Steps

Have a bot that has the `manage_message` permission.  
Have it try to suppress embeds on its own or other user's messages by editing it `message.edit(suppress=True)`  


### Minimal Reproducible Code

```python
msg = await ctx.send("https://gist.github.com/tailoric/94a58a29d150375584b885e563ed0b0f")
await msg.edit(suppress=True)
```


### Expected Results

The message's embeds getting suppressed (as if pressing the small x on the message in the client)


### Actual Results

Nothing happening. 
Message embeds still are displayed and checking via jishaku the `message.flags.suppress_embeds` is False

### Intents

Intents.all()

### System Information

- Python v3.9.4-final
- discord.py v2.0.0-alpha
    - discord.py pkg_resources: v2.0.0a3795+g89009759
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

I think I already tracked down the problem because the `suppress` kwarg never get actually gets used for setting the message flag:

https://github.com/Rapptz/discord.py/blob/e15415413b24afb13fbb67e4a0c58a35a8ee2a84/discord/message.py#L1307-L1313

See older code version of message.py when it worked:

https://github.com/Rapptz/discord.py/blob/489e5f3288efb9b9e6649447209e1ac1746ccb32/discord/message.py#L1258-L1261

Testing on my own simply doing 

```py
        if suppress is not MISSING:
            flags = MessageFlags._from_value(self.flags.value)
            flags.suppress_embeds = suppress
```

Already solves the problem. 
I can make a pull request for this in a bit if this solution is good enough


Discussion:

Resolving patch:
diff --git a/discord/message.py b/discord/message.py
--- a/discord/message.py
+++ b/discord/message.py
@@ -1306,6 +1306,7 @@ async def edit(
         previous_allowed_mentions = self._state.allowed_mentions
         if suppress is not MISSING:
             flags = MessageFlags._from_value(self.flags.value)
+            flags.suppress_embeds = suppress
         else:
             flags = MISSING
 


Test patch:
Repository: Rapptz/discord.py

Issue:
Uncommon KeyError crashes bot
### Summary

There's a possibility of a KeyError trying to remove a user from cache by the looks of it

### Reproduction Steps

Run a commands.Bot with all intents

### Minimal Reproducible Code

```python
No code needed to reproduce as it happens outside of anything of mine
```


### Expected Results

The bot to not crash

### Actual Results

The following exception
```
Traceback (most recent call last):
  File "/home/luck/Fate/fate.py", line 487, in <module>
    bot.run()
  File "/home/luck/Fate/fate.py", line 371, in run
    super().run(self.auth["tokens"][self.config["token_id"]])
  File "/home/luck/.local/lib/python3.9/site-packages/discord/client.py", line 704, in run
    return future.result()
  File "/home/luck/.local/lib/python3.9/site-packages/discord/client.py", line 683, in runner
    await self.start(*args, **kwargs)
  File "/home/luck/.local/lib/python3.9/site-packages/discord/client.py", line 647, in start
    await self.connect(reconnect=reconnect)
  File "/home/luck/.local/lib/python3.9/site-packages/discord/shard.py", line 450, in connect
    raise item.error
  File "/home/luck/.local/lib/python3.9/site-packages/discord/shard.py", line 164, in worker
    await self.ws.poll_event()
  File "/home/luck/.local/lib/python3.9/site-packages/discord/gateway.py", line 626, in poll_event
    await self.received_message(msg.data)
  File "/home/luck/.local/lib/python3.9/site-packages/discord/gateway.py", line 576, in received_message
    func(data)
  File "/home/luck/.local/lib/python3.9/site-packages/discord/state.py", line 1371, in parse_guild_scheduled_event_user_remove
    scheduled_event._pop_user(user.id)
  File "/home/luck/.local/lib/python3.9/site-packages/discord/scheduled_event.py", line 569, in _pop_user
    self._users.pop(user_id)
KeyError: 674093928814870538
```

### Intents

all

### System Information

- Python v3.9.7-final
- discord.py v2.0.0-alpha
    - discord.py pkg_resources: v2.0.0a3836+g206c3402
- aiohttp v3.7.4.post0
- system info: Linux 5.13.0-28-generic #31-Ubuntu SMP Thu Jan 13 17:41:06 UTC 2022

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

This didn't occur until after a few hours of being online


Discussion:

Resolving patch:
diff --git a/discord/scheduled_event.py b/discord/scheduled_event.py
--- a/discord/scheduled_event.py
+++ b/discord/scheduled_event.py
@@ -566,4 +566,4 @@ def _add_user(self, user: User) -> None:
         self._users[user.id] = user
 
     def _pop_user(self, user_id: int) -> None:
-        self._users.pop(user_id)
+        self._users.pop(user_id, None)


Test patch:
Repository: Rapptz/discord.py

Issue:
Optional's default doesn't get applied when it encounters parsing error
### Summary

Related to #7386, value of Optional arg is set to None regardless of its default value on parsing error

### Reproduction Steps

1. Add command from "Minimal Reproducible Code"
2. Try running `issue8117 b"lah`.
3. See the issue.

### Minimal Reproducible Code

```python
class SampleCog(commands.Cog):
    @commands.command()
    async def issue8117(self, ctx, opt: Optional[int] = 1, *, rest):
        await ctx.send(f"{opt=} {rest=}")

await bot.add_cog(SampleCog())
```


### Expected Results

I expected `opt`'s value to be `1`

### Actual Results

![image](https://user-images.githubusercontent.com/6032823/172268207-87449f7c-2fce-4588-ac77-0e5bf5fcd4cf.png)


### Intents

discord.Intents.all()

### System Information

```
λ python -m discord -v
- Python v3.8.10-final
- discord.py v2.0.0-alpha
    - discord.py pkg_resources: v2.0.0a4329+g75d57ab3
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19043
```

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -672,7 +672,7 @@ async def transform(self, ctx: Context[BotT], param: Parameter, attachments: _At
             except ArgumentParsingError as exc:
                 if self._is_typing_optional(param.annotation):
                     view.index = previous
-                    return None
+                    return None if param.required else await param.get_default(ctx)
                 else:
                     raise exc
         view.previous = previous


Test patch:
Repository: XanaduAI/strawberryfields

Issue:
Why add batch on last dimension?
It may not matter in the end, but shouldn't [these lines](https://github.com/XanaduAI/strawberryfields/blob/80191c7a0d6b3430ba31228e0e53ffb5c496dfab/strawberryfields/backends/tfbackend/ops.py#L292) be 

```python
t = tf.expand_dims(t, 0)
r = tf.expand_dims(r, 0)
```

to match what is done in the other ops?


Discussion:

Resolving patch:
diff --git a/strawberryfields/backends/tfbackend/ops.py b/strawberryfields/backends/tfbackend/ops.py
--- a/strawberryfields/backends/tfbackend/ops.py
+++ b/strawberryfields/backends/tfbackend/ops.py
@@ -289,8 +289,8 @@ def beamsplitter_matrix(t, r, D, batched=False, save=False, directory=None):
     """creates the two mode beamsplitter matrix"""
     if not batched:
         # put in a fake batch dimension for broadcasting convenience
-        t = tf.expand_dims(t, -1)
-        r = tf.expand_dims(r, -1)
+        t = tf.expand_dims(t, 0)
+        r = tf.expand_dims(r, 0)
     t = tf.cast(tf.reshape(t, [-1, 1, 1, 1, 1, 1]), def_type)
     r = tf.cast(tf.reshape(r, [-1, 1, 1, 1, 1, 1]), def_type)
     mag_t = tf.cast(t, tf.float32)


Test patch:
Repository: XanaduAI/strawberryfields

Issue:
Dependency versions error
#### Issue description
I made a fork of this project and tried to setup a new virtual environment.

```
python -m venv sf-venv
source sf-venv/bin/active.fish
pip install -r requirements.txt
```

However, I got the following error
``` 
ERROR: Cannot install -r requirements.txt (line 4) and numpy>=1.20 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested numpy>=1.20
    tensorflow 2.5.0 depends on numpy~=1.19.2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
```

#### Additional information

If it helps, I am using Python 3.9.4 and pip 21.1.1. 

A quick fix would be to downgrade the version of numpy in requirements.txt and solve the issue, but I am not sure it is the best way to go.



Discussion:
Hi @maxtremblay, thank you for catching this! One quick solution could be downgrading TF from 2.5 until we add a longer-term solution.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@
 
 
 requirements = [
-    "numpy>=1.17.4",
+    "numpy>=1.19.2",
     "scipy>=1.0.0",
     "sympy>=1.5",
     "networkx>=2.0",


Test patch:
Repository: open-mmlab/mmpretrain

Issue:
bug in recall and precision?
hi:
   It seems the  https://github.com/open-mmlab/mmclassification/blob/92438da12a9f8bf0390277be902dc96e6970b54d/mmcls/models/losses/eval_metrics.py#L55
and https://github.com/open-mmlab/mmclassification/blob/92438da12a9f8bf0390277be902dc96e6970b54d/mmcls/models/losses/eval_metrics.py#L37
get inversed?
@LXXXXR @ycxioooong


Discussion:

Resolving patch:
diff --git a/mmcls/models/losses/eval_metrics.py b/mmcls/models/losses/eval_metrics.py
--- a/mmcls/models/losses/eval_metrics.py
+++ b/mmcls/models/losses/eval_metrics.py
@@ -34,7 +34,7 @@ def precision(pred, target):
     confusion_matrix = calculate_confusion_matrix(pred, target)
     with torch.no_grad():
         res = confusion_matrix.diag() / torch.clamp(
-            confusion_matrix.sum(1), min=1)
+            confusion_matrix.sum(0), min=1)
         res = res.mean().item() * 100
     return res
 
@@ -52,7 +52,7 @@ def recall(pred, target):
     confusion_matrix = calculate_confusion_matrix(pred, target)
     with torch.no_grad():
         res = confusion_matrix.diag() / torch.clamp(
-            confusion_matrix.sum(0), min=1)
+            confusion_matrix.sum(1), min=1)
         res = res.mean().item() * 100
     return res
 


Test patch:
diff --git a/tests/test_dataset.py b/tests/test_dataset.py
--- a/tests/test_dataset.py
+++ b/tests/test_dataset.py
@@ -68,16 +68,19 @@ def test_dataset_evaluation():
         dict(gt_label=0),
         dict(gt_label=1),
         dict(gt_label=2),
-        dict(gt_label=1)
+        dict(gt_label=1),
+        dict(gt_label=0)
     ]
-    fake_results = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 1]])
+    fake_results = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 1],
+                             [0, 0, 1]])
     eval_results = dataset.evaluate(
         fake_results, metric=['precision', 'recall', 'f1_score'])
     assert eval_results['precision'] == pytest.approx(
-        (1 + 1 + 1 / 2) / 3 * 100.0)
-    assert eval_results['recall'] == pytest.approx((1 + 1 / 2 + 1) / 3 * 100.0)
+        (1 + 1 + 1 / 3) / 3 * 100.0)
+    assert eval_results['recall'] == pytest.approx(
+        (1 / 2 + 1 / 2 + 1) / 3 * 100.0)
     assert eval_results['f1_score'] == pytest.approx(
-        (1 + 2 / 3 + 2 / 3) / 3 * 100.0)
+        (2 / 3 + 2 / 3 + 1 / 2) / 3 * 100.0)
 
 
 @patch.multiple(BaseDataset, __abstractmethods__=set())