glh123456/OmniGIRL huggingface dataset:
Repository: python/mypy (Python)

Issue:
error: Expected type in class pattern; found "Any" (cannot be ignored, error without line number)
Found a strange bug today: https://mypy-play.net/?mypy=master&python=3.11&gist=5069b99b248041428036a717e52a3476

```python
from pandas import DataFrame, Series
from typing import TypeVar

T = TypeVar("T", Series, DataFrame)

def f(x: T) -> None:
    match x:
        case Series() | DataFrame():  # type: ignore[misc]  # ignore does not work!
            pass
        case _:
            pass
```

This makes `mypy` emit `main.py: error: Expected type in class pattern; found "Any"  [misc]` without any line number. Adding the `# type:ignore[misc]` statement ends up not doing anything. I think it is because both `Series` and `DataFrame` are of `Any`-type (not using `pandas-stubs` here since it still raises too many issues)


**Your Environment**

- Mypy version used: 1.4.0
- Python version used: 3.11


Hints:

Patch:
diff --git a/mypy/checkpattern.py b/mypy/checkpattern.py
--- a/mypy/checkpattern.py
+++ b/mypy/checkpattern.py
@@ -468,7 +468,7 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
                 name = type_info.type.str_with_options(self.options)
             else:
                 name = type_info.name
-            self.msg.fail(message_registry.CLASS_PATTERN_TYPE_REQUIRED.format(name), o.class_ref)
+            self.msg.fail(message_registry.CLASS_PATTERN_TYPE_REQUIRED.format(name), o)
             return self.early_non_match()
 
         new_type, rest_type = self.chk.conditional_types_with_intersection(


Test patch:
diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test
--- a/test-data/unit/check-python310.test
+++ b/test-data/unit/check-python310.test
@@ -1958,3 +1958,23 @@ def redefinition_bad(a: int):
             ...
 
 [builtins fixtures/primitives.pyi]
+
+[case testPatternMatchingClassPatternLocation]
+# See https://github.com/python/mypy/issues/15496
+from some_missing_lib import DataFrame, Series  # type: ignore[import]
+from typing import TypeVar
+
+T = TypeVar("T", Series, DataFrame)
+
+def f(x: T) -> None:
+    match x:
+        case Series() | DataFrame():  # type: ignore[misc]
+            pass
+
+def f2(x: T) -> None:
+    match x:
+        case Series():  # type: ignore[misc]
+            pass
+        case DataFrame():  # type: ignore[misc]
+            pass
+[builtins fixtures/primitives.pyi]
Repository: netty/netty (Java)

Issue:
the result of `ByteBufUtil.indexOf(ByteBuf needle, ByteBuf haystack)`  wrong
### Expected behavior
```
        ByteBuf haystack = Unpooled.copiedBuffer("+PONG\r\n", CharsetUtil.UTF_8);
        ByteBuf needle = Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8);
        haystack.readByte();

        int index = ByteBufUtil.indexOf(needle ,haystack);

        System.out.println(index);
```
expected result is 5.

### Actual behavior
actual result is 4.

### Steps to reproduce

### Minimal yet complete reproducer code (or URL to code)

### Netty version
4.1.73.Final-SNAPSHOT

### JVM version (e.g. `java -version`)
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.10)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.10, mixed mode, sharing)

### OS version (e.g. `uname -a`)
Linux XPS-13-9310 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux




Hints:
Thanks for the report, preparing a fix.

Patch:
diff --git a/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java b/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
--- a/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
+++ b/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
@@ -279,7 +279,7 @@ public static int indexOf(ByteBuf needle, ByteBuf haystack) {
                         --i;
                     }
                     if (i <= memory) {
-                        return j;
+                        return j + bStartIndex;
                     }
                     j += per;
                     memory = m - per - 1;
@@ -304,7 +304,7 @@ public static int indexOf(ByteBuf needle, ByteBuf haystack) {
                         --i;
                     }
                     if (i < 0) {
-                        return j;
+                        return j + bStartIndex;
                     }
                     j += per;
                 } else {


Test patch:
diff --git a/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java b/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java
--- a/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java
+++ b/buffer/src/test/java/io/netty/buffer/ByteBufUtilTest.java
@@ -132,13 +132,13 @@ public void testIndexOf() {
         final ByteBuf needle = Unpooled.copiedBuffer("abc12", CharsetUtil.UTF_8);
         haystack.readerIndex(1);
         needle.readerIndex(1);
-        assertEquals(0, ByteBufUtil.indexOf(needle, haystack));
+        assertEquals(1, ByteBufUtil.indexOf(needle, haystack));
         haystack.readerIndex(2);
         needle.readerIndex(3);
-        assertEquals(1, ByteBufUtil.indexOf(needle, haystack));
+        assertEquals(3, ByteBufUtil.indexOf(needle, haystack));
         haystack.readerIndex(1);
         needle.readerIndex(2);
-        assertEquals(1, ByteBufUtil.indexOf(needle, haystack));
+        assertEquals(2, ByteBufUtil.indexOf(needle, haystack));
         haystack.release();
 
         haystack = new WrappedByteBuf(Unpooled.copiedBuffer("abc123", CharsetUtil.UTF_8));
Repository: netty/netty (Java)

Issue:
CloseWebSocketFrame statusCode() get unexpected results
Set the  CloseWebSocketFrame code to 60000, and the result obtained by statusCode() is negative;

The WebSocket protocol states that Code is  a 2-byte unsigned integer (in network byte order)，But netty acquisition is obtained by signs.
![image](https://user-images.githubusercontent.com/11245691/211527112-5c0f2923-c6ba-4d29-9d4b-da5b228dcbdd.png)

![image](https://user-images.githubusercontent.com/11245691/211527879-19400bf7-f95c-4394-8301-8e3567245e63.png)

Here, getShort should be changed to getUnsignedShort.

Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.80

JVM version (e.g. java -version)
openjdk 1.8.0_272

OS version (e.g. uname -a)
linux 4.19.36 aarch64


Hints:
@zhangjinying can you do a PR with the change and a test ? 
> @zhangjinying can you do a PR with the change and a test ?

👌

Patch:
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java
--- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrame.java
@@ -135,7 +135,7 @@ public int statusCode() {
             return -1;
         }
 
-        return binaryData.getShort(binaryData.readerIndex());
+        return binaryData.getUnsignedShort(binaryData.readerIndex());
     }
 
     /**


Test patch:
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrameTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrameTest.java
--- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrameTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/CloseWebSocketFrameTest.java
@@ -80,6 +80,15 @@ void testNonZeroReaderIndex() {
                 WebSocketCloseStatus.NORMAL_CLOSURE.code(), WebSocketCloseStatus.NORMAL_CLOSURE.reasonText());
     }
 
+    @Test
+    void testCustomCloseCode() {
+        ByteBuf buffer = Unpooled.buffer().writeZero(1);
+        buffer.writeShort(60000)
+                .writeCharSequence("Custom close code", CharsetUtil.US_ASCII);
+        doTestValidCode(new CloseWebSocketFrame(true, 0, buffer.skipBytes(1)),
+                60000, "Custom close code");
+    }
+
     private static void doTestInvalidCode(ThrowableAssert.ThrowingCallable callable) {
         assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(callable);
     }
Repository: netty/netty (Java)

Issue:
Display which header failed validation
### Expected behavior

Currently if a HeaderValue fails validation we get an IllegalArgumentException which has the message `a header value contains prohibited character {some_invalid_character} at index {index}`. Seeing this in production makes it hard to debug which header is having this problem.

### Actual behavior
We should instead have the message, `Header value for {header_name} contains prohibited character {some_invalid_character} at index {index}

To fix this I am suggesting to change the interface of ValueValidator to also take in the key which will be purely used for adding debug information.


Hints:

Patch:
diff --git a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java
--- a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java
+++ b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java
@@ -1013,7 +1013,11 @@ protected void validateName(NameValidator<K> validator, boolean forAdd, K name)
     }
 
     protected void validateValue(ValueValidator<V> validator, K name, V value) {
-        validator.validate(value);
+        try {
+            validator.validate(value);
+        } catch (IllegalArgumentException e) {
+            throw new IllegalArgumentException("Validation failed for header '" + name + "'", e);
+        }
     }
 
     protected HeaderEntry<K, V> newHeaderEntry(int h, K name, V value, HeaderEntry<K, V> next) {


Test patch:
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/DefaultHttpHeadersTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/DefaultHttpHeadersTest.java
--- a/codec-http/src/test/java/io/netty/handler/codec/http/DefaultHttpHeadersTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/DefaultHttpHeadersTest.java
@@ -238,23 +238,25 @@ public void setObjectIterable() {
     @Test
     public void setCharSequenceValidatesValue() {
         final DefaultHttpHeaders headers = newDefaultDefaultHttpHeaders();
-        assertThrows(IllegalArgumentException.class, new Executable() {
+        IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, new Executable() {
             @Override
             public void execute() throws Throwable {
                 headers.set(HEADER_NAME, ILLEGAL_VALUE);
             }
         });
+        assertTrue(exception.getMessage().contains(HEADER_NAME));
     }
 
     @Test
     public void setIterableValidatesValue() {
         final DefaultHttpHeaders headers = newDefaultDefaultHttpHeaders();
-        assertThrows(IllegalArgumentException.class, new Executable() {
+        IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, new Executable() {
             @Override
             public void execute() throws Throwable {
                 headers.set(HEADER_NAME, Collections.singleton(ILLEGAL_VALUE));
             }
         });
+        assertTrue(exception.getMessage().contains(HEADER_NAME));
     }
 
     @Test
Repository: netty/netty (Java)

Issue:
Possible issues with SelectedSelectionKeySet in non-linux operating systems
`SelectedSelectionKeySet` doesn't implement `contains()` method. Or at least it returns always false. This may create issues in non-linux operating systems.

To give you more context, in my work, like you do, we try to not produce garbage by replacing `HashSet` with something similar to `SelectedSelectionKeySet`. Actually this trick is something we learned from netty.

So while investigating a recent bug, I realized lack of correct implementation of `contains()` method creates problems in macos (and very possibly windows as well). I tried to summarize my finding in here: https://github.com/hazelcast/hazelcast/pull/24267

I do think this issue effects netty as well.


Hints:
Good find, we'll take a look.

Patch:
diff --git a/transport/src/main/java/io/netty/channel/nio/SelectedSelectionKeySet.java b/transport/src/main/java/io/netty/channel/nio/SelectedSelectionKeySet.java
--- a/transport/src/main/java/io/netty/channel/nio/SelectedSelectionKeySet.java
+++ b/transport/src/main/java/io/netty/channel/nio/SelectedSelectionKeySet.java
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 
 final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
 
@@ -51,6 +52,13 @@ public boolean remove(Object o) {
 
     @Override
     public boolean contains(Object o) {
+        SelectionKey[] array = keys;
+        for (int i = 0, s = size; i < s; i++) {
+            SelectionKey k = array[i];
+            if (k.equals(o)) {
+                return true;
+            }
+        }
         return false;
     }
 


Test patch:
diff --git a/transport/src/test/java/io/netty/channel/nio/SelectedSelectionKeySetTest.java b/transport/src/test/java/io/netty/channel/nio/SelectedSelectionKeySetTest.java
--- a/transport/src/test/java/io/netty/channel/nio/SelectedSelectionKeySetTest.java
+++ b/transport/src/test/java/io/netty/channel/nio/SelectedSelectionKeySetTest.java
@@ -102,8 +102,8 @@ public void contains() {
         SelectedSelectionKeySet set = new SelectedSelectionKeySet();
         assertTrue(set.add(mockKey));
         assertTrue(set.add(mockKey2));
-        assertFalse(set.contains(mockKey));
-        assertFalse(set.contains(mockKey2));
+        assertTrue(set.contains(mockKey));
+        assertTrue(set.contains(mockKey2));
         assertFalse(set.contains(mockKey3));
     }
Repository: netty/netty (Java)

Issue:
Malformed ipv6 through proxy
### Expected behavior

The CONNECT request send an well-formed ipv6
CONNECT [2001:0000:130F:0000:0000:09C0:876A:130B]:443
simple bracket

### Actual behavior
The CONNECT request send an malformed ipv6
CONNECT [[2001:0000:130F:0000:0000:09C0:876A:130B]]:443
double bracket

### Steps to reproduce
Sending a https request from an IPV4 network to an IPV6 server through http proxy

### Minimal yet complete reproducer code (or URL to code)
public static String formatHostnameForHttp(InetSocketAddress addr) {
        String hostString = NetUtil.getHostname(addr);
        if (NetUtil.isValidIpV6Address(hostString)) {
            if (!addr.isUnresolved()) {
                hostString = NetUtil.toAddressString(addr.getAddress());
            }

            return '[' + hostString + ']';
        } else {
            return hostString;
        }
    }
When ipv6 is [2001:0000:130F:0000:0000:09C0:876A:130B], the isValidIpV6Address return true, the addr is Unresolved (because the ipv6 is behind the proxy), but brackets is always added and the final result contains double brackets

### Netty version
4.1.107
### JVM version (e.g. `java -version`)
17
### OS version (e.g. `uname -a`)



Hints:
@dbeau35 we love PRs

Patch:
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java
--- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java
@@ -547,7 +547,11 @@ public static String formatHostnameForHttp(InetSocketAddress addr) {
         if (NetUtil.isValidIpV6Address(hostString)) {
             if (!addr.isUnresolved()) {
                 hostString = NetUtil.toAddressString(addr.getAddress());
+            } else if (hostString.charAt(0) == '[' && hostString.charAt(hostString.length() - 1) == ']') {
+                // If IPv6 address already contains brackets, let's return as is.
+                return hostString;
             }
+
             return '[' + hostString + ']';
         }
         return hostString;


Test patch:
diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java
--- a/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java
+++ b/codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java
@@ -379,6 +379,12 @@ public void testIpv6Unresolved()  {
         assertEquals("[::1]", HttpUtil.formatHostnameForHttp(socketAddress));
     }
 
+    @Test
+    public void testIpv6UnresolvedExplicitAddress()  {
+        InetSocketAddress socketAddress = InetSocketAddress.createUnresolved("[2001:4860:4860:0:0:0:0:8888]", 8080);
+        assertEquals("[2001:4860:4860:0:0:0:0:8888]", HttpUtil.formatHostnameForHttp(socketAddress));
+    }
+
     @Test
     public void testIpv4() throws Exception  {
         InetSocketAddress socketAddress = new InetSocketAddress(InetAddress.getByName("10.0.0.1"), 8080);
Repository: tqdm/tqdm (Python)

Issue:
When 'index' or 'columns' is passed as pandas axis, convert to corres…
…ponding int

- [x] I have visited the [source website], and in particular
  read the [known issues]
- [x] I have searched through the [issue tracker] for duplicates
- [ ] I have mentioned version numbers, operating system and
  environment, where applicable:
  ```python
  import tqdm, sys
  print(tqdm.__version__, sys.version, sys.platform)
  ```
- [x] If applicable, I have mentioned the relevant/related issue(s)

  [source website]: https://github.com/tqdm/tqdm/
  [known issues]: https://github.com/tqdm/tqdm/#faq-and-known-issues
  [issue tracker]: https://github.com/tqdm/tqdm/issues?q=



Hints:
# [Codecov](https://codecov.io/gh/tqdm/tqdm/pull/570?src=pr&el=h1) Report
> Merging [#570](https://codecov.io/gh/tqdm/tqdm/pull/570?src=pr&el=desc) into [master](https://codecov.io/gh/tqdm/tqdm/commit/19cd7d735a235177b7f8a4413391226c4aac0c8d?src=pr&el=desc) will **decrease** coverage by `0.57%`.
> The diff coverage is `0%`.



```diff
@@            Coverage Diff            @@
##           master    #570      +/-   ##
=========================================
- Coverage   99.27%   98.7%   -0.58%     
=========================================
  Files           8       8              
  Lines         692     696       +4     
  Branches      123     125       +2     
=========================================
  Hits          687     687              
- Misses          3       5       +2     
- Partials        2       4       +2
```

A performance test failed on Python 2.7. I'm not sure whether or how to address this issue.

Patch:
diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py
--- a/tqdm/_tqdm.py
+++ b/tqdm/_tqdm.py
@@ -581,6 +581,10 @@ def inner(df, func, *args, **kwargs):
                             not isinstance(df, _Rolling_and_Expanding):
                         # DataFrame or Panel
                         axis = kwargs.get('axis', 0)
+                        if axis == 'index':
+                            axis = 0
+                        elif axis == 'columns':
+                            axis = 1
                         # when axis=0, total is shape[axis1]
                         total = df.size // df.shape[axis]
 


Test patch:
diff --git a/tqdm/tests/tests_pandas.py b/tqdm/tests/tests_pandas.py
--- a/tqdm/tests/tests_pandas.py
+++ b/tqdm/tests/tests_pandas.py
@@ -104,7 +104,7 @@ def task_func(x):
         assert res1.equals(res2)
 
         # apply
-        for axis in [0, 1]:
+        for axis in [0, 1, 'index', 'columns']:
             res3 = df.progress_apply(task_func, axis=axis)
             res4 = df.apply(task_func, axis=axis)
             assert res3.equals(res4)
Repository: tqdm/tqdm (Python)

Issue:
Fix a typo in error message
Was having some issues in google colab, there I found this error message with a typo


Hints:

Patch:
diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py
--- a/tqdm/_tqdm.py
+++ b/tqdm/_tqdm.py
@@ -581,6 +581,10 @@ def inner(df, func, *args, **kwargs):
                             not isinstance(df, _Rolling_and_Expanding):
                         # DataFrame or Panel
                         axis = kwargs.get('axis', 0)
+                        if axis == 'index':
+                            axis = 0
+                        elif axis == 'columns':
+                            axis = 1
                         # when axis=0, total is shape[axis1]
                         total = df.size // df.shape[axis]
 
diff --git a/tqdm/_tqdm_notebook.py b/tqdm/_tqdm_notebook.py
--- a/tqdm/_tqdm_notebook.py
+++ b/tqdm/_tqdm_notebook.py
@@ -102,7 +102,7 @@ def status_printer(_, total=None, desc=None, ncols=None):
         except NameError:
             # #187 #451 #558
             raise ImportError(
-                "IntProgress not found. Please update juputer and ipywidgets."
+                "IntProgress not found. Please update jupyter and ipywidgets."
                 " See https://ipywidgets.readthedocs.io/en/stable"
                 "/user_install.html")
 


Test patch:
diff --git a/tqdm/tests/tests_pandas.py b/tqdm/tests/tests_pandas.py
--- a/tqdm/tests/tests_pandas.py
+++ b/tqdm/tests/tests_pandas.py
@@ -33,12 +33,12 @@ def test_pandas_rolling_expanding():
         tqdm.pandas(file=our_file, leave=True, ascii=True)
 
         series = pd.Series(randint(0, 50, (123,)))
-        res1 = series.rolling(10).progress_apply(lambda x: 1)
-        res2 = series.rolling(10).apply(lambda x: 1)
+        res1 = series.rolling(10).progress_apply(lambda x: 1, raw=True)
+        res2 = series.rolling(10).apply(lambda x: 1, raw=True)
         assert res1.equals(res2)
 
-        res3 = series.expanding(10).progress_apply(lambda x: 2)
-        res4 = series.expanding(10).apply(lambda x: 2)
+        res3 = series.expanding(10).progress_apply(lambda x: 2, raw=True)
+        res4 = series.expanding(10).apply(lambda x: 2, raw=True)
         assert res3.equals(res4)
 
         expects = ['114it']  # 123-10+1
@@ -104,7 +104,7 @@ def task_func(x):
         assert res1.equals(res2)
 
         # apply
-        for axis in [0, 1]:
+        for axis in [0, 1, 'index', 'columns']:
             res3 = df.progress_apply(task_func, axis=axis)
             res4 = df.apply(task_func, axis=axis)
             assert res3.equals(res4)