PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: OceanParcels/Parcels (python)

Issue:
Create a `grid.negate_depth` method to swap the sign of depth fields?
Since the sign/orientation of the depth vector is not standardised in oceanography, users may sometimes need to negate a `grid.depth` field. See e.g. https://github.com/OceanParcels/virtualship/pull/75. Especially since `grid._depth` is a private attribute, this is not trivial to users.

It might thus be useful to add a simple `grid.negate_depth()`method that simply does
```python
def negate_depth(self):
    self._depth = -self._depth
```

Pull request:
Adding support for grid.negate_depth() method
This PR adds a `grid.negate_depth()` method, which can be useful when the depth needs to be flipped from positive to negative values. This is the case for example in the `VirtualShip` package:
https://github.com/OceanParcels/virtualship/blob/44eae19e55545166c446e8eabe7c76ab13d7344b/src/virtualship/expedition/input_data.py#L98-L100

Note that this method does _not_ change the direction of the vertical velocity; for that users need to add a `fieldset.W.set_scaling_factor(-1.0)`

This fixes #1746 

Patch:
diff --git a/parcels/grid.py b/parcels/grid.py
index 9b7a6631..382cc0f2 100644
--- a/parcels/grid.py
+++ b/parcels/grid.py
@@ -114,6 +114,13 @@ class Grid:
     def depth(self):
         return self._depth
 
+    def negate_depth(self):
+        """Method to flip the sign of the depth dimension of a Grid.
+        Note that this method does _not_ change the direction of the vertical velocity;
+        for that users need to add a fieldset.W.set_scaling_factor(-1.0)
+        """
+        self._depth = -self._depth
+
     @property
     def mesh(self):
         return self._mesh


Test patch:
diff --git a/tests/test_grids.py b/tests/test_grids.py
index 5e336af1..ccc8230e 100644
--- a/tests/test_grids.py
+++ b/tests/test_grids.py
@@ -112,6 +112,16 @@ def test_time_format_in_grid():
         RectilinearZGrid(lon, lat, time=time)
 
 
+def test_negate_depth():
+    depth = np.linspace(0, 5, 10, dtype=np.float32)
+    fieldset = FieldSet.from_data(
+        {"U": np.zeros((10, 1, 1)), "V": np.zeros((10, 1, 1))}, {"lon": [0], "lat": [0], "depth": depth}
+    )
+    assert np.all(fieldset.gridset.grids[0].depth == depth)
+    fieldset.U.grid.negate_depth()
+    assert np.all(fieldset.gridset.grids[0].depth == -depth)
+
+
 def test_avoid_repeated_grids():
     lon_g0 = np.linspace(0, 1000, 11, dtype=np.float32)
     lat_g0 = np.linspace(0, 1000, 11, dtype=np.float32)
Repository: pypa/setuptools (python)

Issue:
Warning not filtered as supposed to
The warning emitted for missing standard script name in [py36compat.py](https://github.com/pypa/setuptools/blob/master/setuptools/command/py36compat.py#L76) is not suppressed by [`manifest_maker.warn`](https://github.com/pypa/setuptools/blob/master/setuptools/command/egg_info.py#L558) but seems to be supposed to.

I found this while exploring a setup.py as a directory containing a `__main__.py`.  I happened to run

```
python setup.py/__main__.py
```

and I had a warning about the file `__main__.py` missing.

You can suppress the warning by using the `script_name` keyword argument of `setuptools.setup` like so:

```
from setuptools import setup

setup(
    name="mypackage",
    # ... a plethora of other kwargs
    script_name="setup.py"
)
```


Pull request:
Also suppress warning for a single file missing
Replaces #826
Fixes #825

In order to make a test without adding mocks or other monkeys patches, I extracted the check for suppression in a static method.

Patch:
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index 6cc8f4c45..6f8fd8744 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -554,10 +554,17 @@ class manifest_maker(sdist):
         msg = "writing manifest file '%s'" % self.manifest
         self.execute(write_file, (self.manifest, files), msg)
 
-    def warn(self, msg):  # suppress missing-file warnings from sdist
-        if not msg.startswith("standard file not found:"):
+    def warn(self, msg):
+        if not self._should_suppress_warning(msg):
             sdist.warn(self, msg)
 
+    @staticmethod
+    def _should_suppress_warning(msg):
+        """
+        suppress missing-file warnings from sdist
+        """
+        return re.match(r"standard file .*not found", msg)
+
     def add_defaults(self):
         sdist.add_defaults(self)
         self.filelist.append(self.template)


Test patch:
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 12c104972..dc41bc1f2 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -4,7 +4,7 @@ import re
 import stat
 import sys
 
-from setuptools.command.egg_info import egg_info
+from setuptools.command.egg_info import egg_info, manifest_maker
 from setuptools.dist import Distribution
 from setuptools.extern.six.moves import map
 
@@ -237,6 +237,15 @@ class TestEggInfo(object):
         pkginfo = os.path.join(egg_info_dir, 'PKG-INFO')
         assert 'Requires-Python: >=1.2.3' in open(pkginfo).read().split('\n')
 
+    def test_manifest_maker_warning_suppresion(self):
+        fixtures = [
+            "standard file not found: should have one of foo.py, bar.py",
+            "standard file 'setup.py' not found"
+        ]
+
+        for msg in fixtures:
+            assert manifest_maker._should_suppress_warning(msg)
+
     def _run_install_command(self, tmpdir_cwd, env, cmd=None, output=None):
         environ = os.environ.copy().update(
             HOME=env.paths['home'],
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 176
Good morning! Here's your coding interview problem for today.

This problem was asked by Bloomberg.

Determine whether there exists a one-to-one character mapping from one string s1 to another s2.

For example, given `s1 = abc` and `s2 = bcd`, return `true` since we can map a to b, b to c, and c to d.

Given `s1 = foo` and `s2 = bar`, return `false` since the o cannot map to two characters.

Pull request:
Day176
Resolves #364.

Patch:
diff --git a/README.md b/README.md
index 782c346..eede14d 100644
--- a/README.md
+++ b/README.md
@@ -185,5 +185,6 @@ problems from
 * [Day 171](https://github.com/vaskoz/dailycodingproblem-go/issues/356)
 * [Day 172](https://github.com/vaskoz/dailycodingproblem-go/issues/358)
 * [Day 173](https://github.com/vaskoz/dailycodingproblem-go/issues/360)
+* [Day 176](https://github.com/vaskoz/dailycodingproblem-go/issues/364)
 * [Day 177](https://github.com/vaskoz/dailycodingproblem-go/issues/365)
 * [Day 178](https://github.com/vaskoz/dailycodingproblem-go/issues/367)
diff --git a/day176/problem.go b/day176/problem.go
new file mode 100644
index 0000000..b505f9b
--- /dev/null
+++ b/day176/problem.go
@@ -0,0 +1,17 @@
+package day176
+
+// DoesMappingExist returns true if a 1-to-1 mapping exists.
+func DoesMappingExist(s1, s2 string) bool {
+	if len(s1) != len(s2) {
+		return false
+	}
+	m := make(map[rune]rune)
+	for i, r := range s1 {
+		if t, exists := m[r]; exists && rune(s2[i]) != t {
+			return false
+		} else if !exists {
+			m[r] = rune(s2[i])
+		}
+	}
+	return true
+}


Test patch:
diff --git a/day176/problem_test.go b/day176/problem_test.go
new file mode 100644
index 0000000..02dd516
--- /dev/null
+++ b/day176/problem_test.go
@@ -0,0 +1,29 @@
+package day176
+
+import "testing"
+
+var testcases = []struct {
+	s1, s2 string
+	exists bool
+}{
+	{"abc", "bcd", true},
+	{"foo", "bar", false},
+	{"a", "bb", false},
+}
+
+func TestDoesMappingExist(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := DoesMappingExist(tc.s1, tc.s2); result != tc.exists {
+			t.Errorf("Expected %v got %v", tc.exists, result)
+		}
+	}
+}
+
+func BenchmarkDoesMappingExist(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			DoesMappingExist(tc.s1, tc.s2)
+		}
+	}
+}
Repository: ember-cli/eslint-plugin-ember (js)

Issue:
False positives with `no-array-prototype-extensions` rule
Further to #1534 there are additional false positives when this rule is run against [ember-file-upload](https://github.com/adopted-ember-addons/ember-file-upload/runs/7440106845?check_suite_focus=true).

- `.clear()` on a `Set` (probably on a Map, too)
- `RSVP.reject()`

If I have time tomorrow I'll open a PR to address.

Pull request:
Fix false positives with `RSVP.Promise.reject()` in `no-array-prototype-extensions` rule
Fixes #1537 (some related scenarios).

Patch:
diff --git a/lib/rules/no-array-prototype-extensions.js b/lib/rules/no-array-prototype-extensions.js
index 98fb1c5f..8ca3b6c1 100644
--- a/lib/rules/no-array-prototype-extensions.js
+++ b/lib/rules/no-array-prototype-extensions.js
@@ -66,6 +66,9 @@ const KNOWN_NON_ARRAY_FUNCTION_CALLS = new Set([
 
   // RSVP.reject
   'RSVP.reject',
+  'RSVP.Promise.reject',
+  'Ember.RSVP.reject',
+  'Ember.RSVP.Promise.reject',
 
   // *storage.clear()
   'window.localStorage.clear',


Test patch:
diff --git a/tests/lib/rules/no-array-prototype-extensions.js b/tests/lib/rules/no-array-prototype-extensions.js
index c698028f..bb307d6a 100644
--- a/tests/lib/rules/no-array-prototype-extensions.js
+++ b/tests/lib/rules/no-array-prototype-extensions.js
@@ -48,17 +48,23 @@ ruleTester.run('no-array-prototype-extensions', rule, {
     'Promise.reject();',
     'Promise.reject("some reason");',
     'reject();',
+    'this.reject();',
 
     // Global non-array class (RSVP.reject)
     'RSVP.reject();',
     'RSVP.reject("some reason");',
+    'RSVP.Promise.reject();',
+    'Ember.RSVP.reject();',
+    'Ember.RSVP.Promise.reject();',
 
     // Global non-array class (*storage.clear)
     'window.localStorage.clear();',
     'window.sessionStorage.clear();',
     'localStorage.clear();',
     'sessionStorage.clear();',
+    'sessionStorage?.clear();',
     'clear();',
+    'this.clear();',
 
     // Global non-array class (location.replace)
     'window.document.location.replace(url)',
Repository: jlongster/prettier (js)

Issue:
Missing parenthesis for class expressions left of a member expression
```js
(class {})[1];
(class {}).a;
```

outputs

```js
class {}[1];
class {}.a;
```

which is invalid

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22(class%20%7B%7D)%5B1%5D%3B%5Cn(class%20%7B%7D).a%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Afalse%2C%22doc%22%3Afalse%7D%7D

Pull request:
Add parenthesis for class expression on left of member expression
Fixes #414

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index a531a96fe..44800b3c4 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -392,6 +392,7 @@ FPp.needsParens = function(assumeExpressionContext) {
         case "LogicalExpression":
         case "LogicalExpression":
         case "NewExpression":
+        case "ExportDefaultDeclaration":
           return true;
 
         case "CallExpression":
@@ -449,6 +450,8 @@ FPp.needsParens = function(assumeExpressionContext) {
           if (parent.callee === node) {
             return true;
           }
+        case "MemberExpression":
+          return name === "object" && parent.object === node;
       }
 
       return false;


Test patch:
diff --git a/tests/classes/__snapshots__/jsfmt.spec.js.snap b/tests/classes/__snapshots__/jsfmt.spec.js.snap
index 0a7f5ef2d..c3208a09b 100644
--- a/tests/classes/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/classes/__snapshots__/jsfmt.spec.js.snap
@@ -264,6 +264,15 @@ class Foo {} // error, shadows type Foo
 "
 `;
 
+exports[`test member.js 1`] = `
+"(class {})[1];
+(class {}).a;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+(class {})[1];
+(class {}).a;
+"
+`;
+
 exports[`test statics.js 1`] = `
 "/* @flow */
 
diff --git a/tests/classes/member.js b/tests/classes/member.js
new file mode 100644
index 000000000..128236eba
--- /dev/null
+++ b/tests/classes/member.js
@@ -0,0 +1,2 @@
+(class {})[1];
+(class {}).a;
diff --git a/tests/export_default/__snapshots__/jsfmt.spec.js.snap b/tests/export_default/__snapshots__/jsfmt.spec.js.snap
index 7a5c5da54..ac0cace2d 100644
--- a/tests/export_default/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/export_default/__snapshots__/jsfmt.spec.js.snap
@@ -5,6 +5,13 @@ module.exports = require(\"M\");
 "
 `;
 
+exports[`test body.js 1`] = `
+"export default (class {}[1] = 1);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+export default (class {}[1] = 1);
+"
+`;
+
 exports[`test test.js 1`] = `
 "var M = require(\'M\');
 var N = require(\'N\');
diff --git a/tests/export_default/body.js b/tests/export_default/body.js
new file mode 100644
index 000000000..7a2f3c475
--- /dev/null
+++ b/tests/export_default/body.js
@@ -0,0 +1,1 @@
+export default (class {}[1] = 1);
Repository: sindresorhus/got (ts)

Issue:
Cannot use custom agent with got.extend()
Hi,

Because of unfortunate [deepFreeze of defaults](https://github.com/sindresorhus/got/blob/b8a086f8da53d57fdf11ba49eefa01d778a4f69f/source/create.js#L62) I cannot longer use any agent defined in the way like:

```javascript
const agents = require("./keepalive");
const got = require("got");

const request = exports.request = got.extend({
  timeout: 4000,
  agent: {
    http: agents.httpAgent,
    https: agents.httpsAgent
  }
});
```

This code will always break with error like `Cannot add property localhost:8080:, object is not extensible` as internal structures of agent object are also freezed. I do not want to set it per request as it is the main reason of `got.extend` existence...


Pull request:
Don't freeze any other values than plain objects and arrays
Fixes #576

Patch:
diff --git a/source/deep-freeze.js b/source/deep-freeze.js
index b4ded11..5052b71 100644
--- a/source/deep-freeze.js
+++ b/source/deep-freeze.js
@@ -3,7 +3,7 @@ const is = require('@sindresorhus/is');
 
 module.exports = function deepFreeze(object) {
 	for (const [key, value] of Object.entries(object)) {
-		if (is.object(value)) {
+		if (is.plainObject(value) || is.array(value)) {
 			deepFreeze(object[key]);
 		}
 	}


Test patch:
diff --git a/test/create.js b/test/create.js
index ddafa80..4e688b8 100644
--- a/test/create.js
+++ b/test/create.js
@@ -1,3 +1,4 @@
+import http from 'http';
 import {URL} from 'url';
 import test from 'ava';
 import got from '../source';
@@ -145,6 +146,14 @@ test('no tampering with defaults', t => {
 	t.is(instance2.defaults.options.baseUrl, 'example');
 });
 
+test('only plain objects are freezed', async t => {
+	const instance = got.extend({
+		agent: new http.Agent({keepAlive: true})
+	});
+
+	await t.notThrowsAsync(() => instance(s.url));
+});
+
 test('defaults are cloned on instance creation', t => {
 	const options = {foo: 'bar', hooks: {beforeRequest: [() => {}]}};
 	const instance = got.create({options});
Repository: skx/monkey (go)

Issue:
Regex Built In should avoid MustCompile to avoid potential panic
https://github.com/skx/monkey/blob/master/evaluator/stdlib_core.go#L174C59-L175C2

Instead of using MustCompile, you probably should use Compile so you can capture the error and return it. Potentially even caching the regex compiled.


```go
var regexCacheLock sync.Mutex
var regexCache = map[string]*regexp.Regexp{}

func compileRegex(reg string) (*regexp.Regexp, error) {
    regexCacheLock.Lock()
    defer regexCacheLock.Unlock()
  
    reg, ok := regexCache[reg]
    if !ok {
        reg, err = regexp.MustCompile(reg)
        if err != nil {
            return nil, err
        }
        regexCache[reg] = reg
    }
  
    return reg, nil
}

...

// regular expression match
func matchFun(args ...object.Object) object.Object {

    // reg := regexp.MustCompile(args[0].(*object.String).Value)
    // Feel free to replace `compileRegex` with `regexp.Compile` if you dont want to use the cache.
    reg, err := compileRegex(args[0].(*object.String).Value)
    if err != nil {
        return newError("failed to compile regex: %v", err)
    }
```

Pull request:
94 - Ensure bogus regexps are caught
We previously handled malformed regular expressions when using them as literals, but it was noted by @DeadlySurgeon that the `match` function had no such handling.

This pull-request will close #94 by ensuring that bogus regular expressions are caught even in the `match` function.

Patch:
diff --git a/evaluator/stdlib_core.go b/evaluator/stdlib_core.go
index 3823354..21593ac 100644
--- a/evaluator/stdlib_core.go
+++ b/evaluator/stdlib_core.go
@@ -171,7 +171,11 @@ func matchFun(args ...object.Object) object.Object {
 	//
 	// Compile and match
 	//
-	reg := regexp.MustCompile(args[0].(*object.String).Value)
+	reg, err := regexp.Compile(args[0].(*object.String).Value)
+	if err != nil {
+		return newError("failed to compile regexp %s: %s",
+			args[0].Inspect(), err)
+	}
 	res := reg.FindStringSubmatch(args[1].(*object.String).Value)
 
 	if len(res) > 0 {


Test patch:
diff --git a/evaluator/evaluator_test.go b/evaluator/evaluator_test.go
index 454e4b0..757efbc 100644
--- a/evaluator/evaluator_test.go
+++ b/evaluator/evaluator_test.go
@@ -688,3 +688,36 @@ return total;
 	}
 
 }
+
+// TestIssue94 tests #94 - that malformed regexps are caught
+func TestIssue94(t *testing.T) {
+	literal := `
+name = "Steve"
+
+if ( name ~= /+/i ) { puts( "Hello\n" ); }
+`
+	ev1 := testEval(literal)
+	er1, ok1 := ev1.(*object.Error)
+	if !ok1 {
+		t.Errorf("Expected an error with a bogus regexp, got none")
+	}
+
+	if !strings.Contains(er1.Inspect(), "parsing regexp") {
+		t.Errorf("Got an error, but not the right one:%v", er1.Inspect())
+	}
+
+	match := `
+name = "Steve"
+
+if (match( "+", name) ) { puts( "Hello\n" ); }
+`
+	ev2 := testEval(match)
+	er2, ok2 := ev2.(*object.Error)
+	if !ok2 {
+		t.Errorf("Expected an error with a bogus regexp, got none")
+	}
+	if !strings.Contains(er2.Inspect(), "parsing regexp") {
+		t.Errorf("Got an error, but not the right one:%v", er2.Inspect())
+	}
+
+}
Repository: keathley/finch (elixir)

Issue:
accept %URI{} as well as binary for url()
https://hexdocs.pm/finch/Finch.html#t:url/0 defines a url as a binary(). I am accustomed to passing around %URI{} structs instead.

Is there a reason you wouldn't also accept (or perhaps only expect) a %URI{} struct?

BTW - love the library, just thought I'd ask.

Pull request:
Accepts a URI struct in request/3/4/5/6
Closes #46 


Patch:
diff --git a/lib/finch.ex b/lib/finch.ex
index 21b759c..5a47775 100644
--- a/lib/finch.ex
+++ b/lib/finch.ex
@@ -66,7 +66,7 @@ defmodule Finch do
   @typedoc """
   A Uniform Resource Locator, the address of a resource on the Web.
   """
-  @type url() :: String.t()
+  @type url() :: String.t() | URI.t()
 
   @typedoc """
   A body associated with a request.
@@ -79,7 +79,7 @@ defmodule Finch do
   ## Options:
     * `:name` - The name of your Finch instance. This field is required.
 
-    * `:pools` - A map specifying the configuration for your pools. The keys should be URLs 
+    * `:pools` - A map specifying the configuration for your pools. The keys should be URLs
     provided as binaries, or the atom `:default` to provide a catch-all configuration to be used
     for any unspecified URLs. See "Pool Configuration Options" below for details on the possible
     map values. Default value is `%{default: [size: #{@default_pool_size}, count: #{
@@ -150,7 +150,16 @@ defmodule Finch do
   end
 
   defp parse_and_normalize_url(url) when is_binary(url) do
-    parsed_uri = URI.parse(url)
+    url
+    |> URI.parse()
+    |> parse_and_normalize_url()
+  end
+
+  defp parse_and_normalize_url(%URI{} = parsed_uri) do
+    normalize_uri(parsed_uri)
+  end
+
+  defp normalize_uri(parsed_uri) do
     normalized_path = parsed_uri.path || "/"
 
     with {:ok, scheme} <- normalize_scheme(parsed_uri.scheme) do


Test patch:
diff --git a/test/finch_test.exs b/test/finch_test.exs
index f153690..6546ecb 100644
--- a/test/finch_test.exs
+++ b/test/finch_test.exs
@@ -169,6 +169,20 @@ defmodule FinchTest do
                end)
     end
 
+    test "successful get request, with query string, when given a %URI{}", %{bypass: bypass} do
+      start_supervised({Finch, name: MyFinch})
+      query_string = "query=value"
+      uri = URI.parse(endpoint(bypass, "?" <> query_string))
+
+      Bypass.expect_once(bypass, "GET", "/", fn conn ->
+        assert conn.query_string == query_string
+        Plug.Conn.send_resp(conn, 200, "OK")
+      end)
+
+      assert {:ok, %{status: 200}} =
+               Finch.request(MyFinch, :get, uri)
+    end
+
     test "raises if unsupported atom request method provided", %{bypass: bypass} do
       assert_raise ArgumentError, ~r/got unsupported atom method :gimme/, fn ->
         Finch.request(MyFinch, :gimme, endpoint(bypass))
Repository: marmelroy/PhoneNumberKit (swift)

Issue:
Parsing doesn't work properly updating from 3.5.10 to 3.6.1
### New Issue Checklist

- [x] Updated PhoneNumberKit to the latest version / Specified the podspec directly from the repo
- [X] Phone number formatted correctly on [JavaScript version](https://htmlpreview.github.io/?https://github.com/google/libphonenumber/blob/master/javascript/i18n/phonenumbers/demo-compiled.html)
- [x] I searched for [existing GitHub issues](https://github.com/marmelroy/PhoneNumberKit)

### Steps to reproduce
```swift
let kit = PhoneNumberKit()
let kitNumber = try kit.parse("420777666555", withRegion: "CZ")
let formattedNumber = kit.format(kitNumber, toType: .international)
XCTAssertEqual(formattedNumber, "+420 777 666 555")
```

##### Expected result

Assert succeed

##### Actual result

It fails with: `PhoneNumberKit.PhoneNumberError.invalidNumber`

### Environment

- Integration through SPM - version `3.6.1`
- Xcode 14.3.1


### Notes

- Our tests caught it - it worked properly on `3.5.10`

Pull request:
Fix #660

Patch:
diff --git a/PhoneNumberKit/PhoneNumberKit.swift b/PhoneNumberKit/PhoneNumberKit.swift
index 4958fedda..811847a03 100644
--- a/PhoneNumberKit/PhoneNumberKit.swift
+++ b/PhoneNumberKit/PhoneNumberKit.swift
@@ -36,7 +36,19 @@ public final class PhoneNumberKit: NSObject {
     ///   - ignoreType: Avoids number type checking for faster performance.
     /// - Returns: PhoneNumber object.
     public func parse(_ numberString: String, withRegion region: String = PhoneNumberKit.defaultRegionCode(), ignoreType: Bool = false) throws -> PhoneNumber {
-        return try self.parseManager.parse(numberString, withRegion: region, ignoreType: ignoreType)
+        let region = region.uppercased()
+        do {
+            return try self.parseManager.parse(numberString, withRegion: region, ignoreType: ignoreType)
+        } catch {
+            guard numberString.first != "+", let regionMetadata = metadataManager.filterTerritories(byCountry: region) else {
+                throw error
+            }
+            let countryCode = String(regionMetadata.countryCode)
+            guard numberString.prefix(countryCode.count) == countryCode else {
+                throw error
+            }
+            return try self.parse("+\(numberString)", withRegion: region, ignoreType: ignoreType)
+        }
     }
 
     /// Parses an array of number strings. Optimised for performance. Invalid numbers are ignored in the resulting array


Test patch:
diff --git a/PhoneNumberKitTests/PhoneNumberKitTests.swift b/PhoneNumberKitTests/PhoneNumberKitTests.swift
index 23cc39668..69012bcf0 100644
--- a/PhoneNumberKitTests/PhoneNumberKitTests.swift
+++ b/PhoneNumberKitTests/PhoneNumberKitTests.swift
@@ -457,4 +457,9 @@ class PhoneNumberKitTests: XCTestCase {
             }
         }
     }
+    
+    func testValidCZNumbers() {
+        let numbers = ["420734593819", "+420734593819", "734593819"]
+        numbers.forEach { XCTAssertTrue(phoneNumberKit.isValidPhoneNumber($0, withRegion: "CZ")) }
+    }
 }