nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: joke2k/faker
Pull request #739 (2018-04-06 13:22:46)

Added random lower and uppercase letters
### What does this changes

Added method to get lowercase and uppercase ASCII letters.

### What was wrong

In my previous PR (#738), I wanted to have a random ASCII letter,
But have to import string or make a small trick.
Here's all is made is the base provider.


Patch:
diff --git a/faker/providers/__init__.py b/faker/providers/__init__.py
index 417a033e..3a12f97e 100644
--- a/faker/providers/__init__.py
+++ b/faker/providers/__init__.py
@@ -91,6 +91,14 @@ class BaseProvider(object):
         return self.generator.random.choice(
             getattr(string, 'letters', string.ascii_letters))
 
+    def random_lowercase_letter(self):
+        """Returns a random lowercase letter (between a-z)."""
+        return self.generator.random.choice(string.ascii_lowercase)
+
+    def random_uppercase_letter(self):
+        """Returns a random letter (between A-Z)."""
+        return self.generator.random.choice(string.ascii_uppercase)
+
     def random_element(self, elements=('a', 'b', 'c')):
         """
         Returns a random element from a passed object.


Test patch:
diff --git a/tests/test_base_provider.py b/tests/test_base_provider.py
index e45c6692..e604912b 100644
--- a/tests/test_base_provider.py
+++ b/tests/test_base_provider.py
@@ -105,3 +105,20 @@ class TestBaseProvider(unittest.TestCase):
             for c in hexified:
                 self.assertIn(c, string.hexdigits[:-6].upper())
                 self.assertNotIn(c, string.hexdigits[-6:].lower())
+
+    def test_random_letter(self):
+        for i in range(100):
+            letter = self.provider.random_letter()
+            self.assertTrue(letter.isalpha())
+
+    def test_random_lowercase_letter(self):
+        for i in range(100):
+            letter = self.provider.random_lowercase_letter()
+            self.assertTrue(letter.isalpha())
+            self.assertEqual(letter.lower(), letter)
+
+    def test_random_uppercase_letter(self):
+        for i in range(100):
+            letter = self.provider.random_uppercase_letter()
+            self.assertTrue(letter.isalpha())
+            self.assertEqual(letter.upper(), letter)
Repository: joke2k/faker
Pull request #744 (2018-04-18 07:55:07)

Add possibility to order artifical ssn numbers
Ref: #725

Adding a new optional parameter (artifical) for FI_fi ssn provider. Default functionality
was not changed, it will provide valid Finnish SSN numbers. If set to true, it will generate
artifical ssn numbers with individual number starting with 9.



Patch:
diff --git a/faker/providers/ssn/fi_FI/__init__.py b/faker/providers/ssn/fi_FI/__init__.py
index ba9c817b..ab329951 100644
--- a/faker/providers/ssn/fi_FI/__init__.py
+++ b/faker/providers/ssn/fi_FI/__init__.py
@@ -7,7 +7,7 @@ import datetime
 
 class Provider(SsnProvider):
 
-    def ssn(self, min_age=0, max_age=105):
+    def ssn(self, min_age=0, max_age=105, artificial=False):
         """
         Returns 11 character Finnish personal identity code (Henkilötunnus,
         HETU, Swedish: Personbeteckning). This function assigns random
@@ -33,7 +33,8 @@ class Provider(SsnProvider):
         birthday = datetime.date.today() - age
         hetu_date = "%02d%02d%s" % (
             birthday.day, birthday.month, str(birthday.year)[-2:])
-        suffix = str(self.generator.random.randrange(2, 899)).zfill(3)
+        range = (900, 999) if artificial is True else (2, 899)
+        suffix = str(self.generator.random.randrange(*range)).zfill(3)
         checksum = _checksum(hetu_date + suffix)
         separator = self._get_century_code(birthday.year)
         hetu = "".join([hetu_date, separator, suffix, checksum])


Test patch:
diff --git a/tests/providers/test_ssn.py b/tests/providers/test_ssn.py
index 42490102..db69201c 100644
--- a/tests/providers/test_ssn.py
+++ b/tests/providers/test_ssn.py
@@ -54,6 +54,16 @@ class TestFiFI(unittest.TestCase):
     def test_ssn_sanity(self):
         for age in range(100):
             self.factory.ssn(min_age=age, max_age=age+1)
+    
+    def test_valid_ssn(self):
+        ssn = self.factory.ssn(artificial=False)
+        individual_number = int(ssn[7:10])
+        self.assertLessEqual(individual_number, 899)
+
+    def test_artifical_ssn(self):
+        ssn = self.factory.ssn(artificial=True)
+        individual_number = int(ssn[7:10])
+        self.assertGreaterEqual(individual_number, 900)
 
 
 class TestHrHR(unittest.TestCase):
Repository: joke2k/faker
Pull request #840 (2018-10-16 18:23:15)

Add bank provider for pl_PL locale
### What does this changes

Adds bank provider for pl_PL locale.

### What was wrong

Bank provider for pl_PL locale didn't exist before.

### How this fixes it

Adds bank provider for pl_PL locale.



Patch:
diff --git a/faker/providers/bank/pl_PL/__init__.py b/faker/providers/bank/pl_PL/__init__.py
new file mode 100644
index 00000000..8fa318ad
--- /dev/null
+++ b/faker/providers/bank/pl_PL/__init__.py
@@ -0,0 +1,6 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    bban_format = '#' * 26
+    country_code = 'PL'


Test patch:
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
index 3a0ae3bb..2e58af46 100644
--- a/tests/providers/test_bank.py
+++ b/tests/providers/test_bank.py
@@ -15,3 +15,18 @@ class TestNoNO(unittest.TestCase):
     def test_bban(self):
         bban = self.factory.bban()
         assert re.match("\d{11}", bban)
+
+
+class TestPlPL(unittest.TestCase):
+    """Tests the bank provider for pl_PL locale"""
+
+    def setUp(self):
+        self.factory = Faker('pl_PL')
+
+    def test_bban(self):
+        bban = self.factory.bban()
+        assert re.match("\d{26}", bban)
+
+    def test_iban(self):
+        iban = self.factory.iban()
+        assert re.match("PL\d{26}", iban)
Repository: joke2k/faker
Pull request #865 (2018-10-31 16:23:08)

sv_SE license plates added
### What does this changes

Added Swedish license plate format.

### What was wrong

```python
fake.license_plate()
 #=> 'RRT-6172'
```

### How this fixes it

```python
fake.license_plate()
 #=> 'VDA 15B'
```

fcurella: Thank you @vilhelmmelkstam !

Could you also add some tests?
vilhelmmelkstam: Did to many mistakes (sorry, quite new at this), will come back and fix what is wrong!
fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/automotive/sv_SE/__init__.py b/faker/providers/automotive/sv_SE/__init__.py
new file mode 100644
index 00000000..1cb540ae
--- /dev/null
+++ b/faker/providers/automotive/sv_SE/__init__.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+
+
+from __future__ import unicode_literals
+from .. import Provider as AutomotiveProvider
+
+
+class Provider(AutomotiveProvider):
+    # Source: https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Sweden
+    # New possible format: https://goo.gl/gSjsnV
+    license_formats = (
+        # Classic format
+        '??? ###',
+        # New possible format
+        '??? ##?',
+    )


Test patch:
diff --git a/tests/providers/test_automotive.py b/tests/providers/test_automotive.py
index 784fe1d0..88c57c5c 100644
--- a/tests/providers/test_automotive.py
+++ b/tests/providers/test_automotive.py
@@ -39,3 +39,13 @@ class TestDeDe(unittest.TestCase):
         plate = self.factory.license_plate()
         assert re.match(r"[A-Z\u00D6\u00DC]{1,3}-[A-Z]{1,2}-\d{1,4}", plate, flags=re.UNICODE), \
             "%s is not in the correct format." % plate
+
+
+class TestSvSE(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Faker('sv_SE')
+
+    def test_sv_SE_plate_format(self):
+        plate = self.factory.license_plate()
+        assert re.match(r"[A-Z]{3} \d{2}[\dA-Z]{1}", plate), "%s is not in the correct format." % plate
Repository: joke2k/faker
Pull request #874 (2018-12-02 08:23:21)

Add categories to Japanese company provider
### What does this changes

Added variety of Japanese company names.

The category list is from Ruby Faker. https://github.com/stympy/faker/blob/master/lib/locales/ja.yml#L28

### What was wrong

Nothing was wrong.

### How this fixes it

Added categories and format patterns.



shirakia: Coveralls says coverage decreased. But this part is completely unrelated to this PR.
Can someone who has WRITE access rebuild travis? It will solve coverage decreasing.

The problem is issued here https://github.com/joke2k/faker/issues/773

Patch:
diff --git a/README.rst b/README.rst
index 69d7185f..6982da41 100644
--- a/README.rst
+++ b/README.rst
@@ -103,7 +103,7 @@ Check the `extended docs`_ for a list of `bundled providers`_ and a list of
 Localization
 ------------
 
-``faker.Factory`` can take a locale as an argument, to return localized
+``faker.Faker`` can take a locale as an argument, to return localized
 data. If no localized provider is found, the factory falls back to the
 default en\_US locale.
 
diff --git a/faker/providers/company/ja_JP/__init__.py b/faker/providers/company/ja_JP/__init__.py
index 649fafad..b650fb06 100644
--- a/faker/providers/company/ja_JP/__init__.py
+++ b/faker/providers/company/ja_JP/__init__.py
@@ -5,10 +5,15 @@ from .. import Provider as CompanyProvider
 
 class Provider(CompanyProvider):
     formats = (
-        '{{company_prefix}} {{last_name}}',
+        '{{company_prefix}}{{last_name}}{{company_category}}',
+        '{{last_name}}{{company_category}}{{company_prefix}}',
     )
 
     company_prefixes = ('株式会社', '有限会社', '合同会社')
+    company_categories = ('水産', '農林', '鉱業', '建設', '食品', '印刷', '電気', 'ガス', '情報', '通信', '運輸', '銀行', '保険')
 
     def company_prefix(self):
         return self.random_element(self.company_prefixes)
+
+    def company_category(self):
+        return self.random_element(self.company_categories)


Test patch:
diff --git a/tests/providers/test_company.py b/tests/providers/test_company.py
index ca6b220b..0334a087 100644
--- a/tests/providers/test_company.py
+++ b/tests/providers/test_company.py
@@ -37,15 +37,19 @@ class TestJaJP(unittest.TestCase):
 
     def test_company(self):
         prefixes = JaProvider.company_prefixes
-
         prefix = self.factory.company_prefix()
         assert isinstance(prefix, six.string_types)
         assert prefix in prefixes
 
+        categories = JaProvider.company_categories
+        category = self.factory.company_category()
+        assert isinstance(category, six.string_types)
+        assert category in categories
+
         company = self.factory.company()
         assert isinstance(company, six.string_types)
-        assert any(prefix in company for prefix in prefixes)
-        assert any(company.startswith(prefix) for prefix in prefixes)
+        assert any(company.startswith(prefix) or company.endswith(prefix) for prefix in prefixes)
+        assert any(category in company for category in categories)
 
 
 class TestPtBR(unittest.TestCase):
Repository: joke2k/faker
Pull request #878 (2018-12-07 11:29:52)

Unit Tests for he_IL Address Provider
### What does this changes

Adds unit tests for ```he_IL``` address provider.

### What was wrong

Address provider for ```he_IL``` was lacking unit tests.

### How this fixes it

Adds the unit tests.



Patch:
diff --git a/faker/providers/company/ja_JP/__init__.py b/faker/providers/company/ja_JP/__init__.py
index 649fafad..b650fb06 100644
--- a/faker/providers/company/ja_JP/__init__.py
+++ b/faker/providers/company/ja_JP/__init__.py
@@ -5,10 +5,15 @@ from .. import Provider as CompanyProvider
 
 class Provider(CompanyProvider):
     formats = (
-        '{{company_prefix}} {{last_name}}',
+        '{{company_prefix}}{{last_name}}{{company_category}}',
+        '{{last_name}}{{company_category}}{{company_prefix}}',
     )
 
     company_prefixes = ('株式会社', '有限会社', '合同会社')
+    company_categories = ('水産', '農林', '鉱業', '建設', '食品', '印刷', '電気', 'ガス', '情報', '通信', '運輸', '銀行', '保険')
 
     def company_prefix(self):
         return self.random_element(self.company_prefixes)
+
+    def company_category(self):
+        return self.random_element(self.company_categories)


Test patch:
diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py
index eb063fdd..b9306bc6 100644
--- a/tests/providers/test_address.py
+++ b/tests/providers/test_address.py
@@ -242,6 +242,21 @@ class TestFrFR(unittest.TestCase):
         assert isinstance(department_number, string_types)
 
 
+class TestHeIL(unittest.TestCase):
+    """ Tests addresses in the he_IL locale """
+
+    def setUp(self):
+        self.factory = Faker('he_IL')
+
+    def test_city_name(self):
+        city_name = self.factory.city_name()
+        assert isinstance(city_name, string_types)
+
+    def test_street_title(self):
+        street_title = self.factory.street_title()
+        assert isinstance(street_title, string_types)
+
+
 class TestFiFI(unittest.TestCase):
     """ Tests in addresses in the fi_FI locale """
 
diff --git a/tests/providers/test_company.py b/tests/providers/test_company.py
index ca6b220b..0334a087 100644
--- a/tests/providers/test_company.py
+++ b/tests/providers/test_company.py
@@ -37,15 +37,19 @@ class TestJaJP(unittest.TestCase):
 
     def test_company(self):
         prefixes = JaProvider.company_prefixes
-
         prefix = self.factory.company_prefix()
         assert isinstance(prefix, six.string_types)
         assert prefix in prefixes
 
+        categories = JaProvider.company_categories
+        category = self.factory.company_category()
+        assert isinstance(category, six.string_types)
+        assert category in categories
+
         company = self.factory.company()
         assert isinstance(company, six.string_types)
-        assert any(prefix in company for prefix in prefixes)
-        assert any(company.startswith(prefix) for prefix in prefixes)
+        assert any(company.startswith(prefix) or company.endswith(prefix) for prefix in prefixes)
+        assert any(category in company for category in categories)
 
 
 class TestPtBR(unittest.TestCase):
Repository: joke2k/faker
Pull request #919 (2019-03-08 12:26:15)

Brazilian RG Feature
### What does this changes
Address Brazilian RG (identity card)

### What was wrong
New feature

### How this fixes it

Fixes  #918 



Patch:
diff --git a/faker/providers/ssn/pt_BR/__init__.py b/faker/providers/ssn/pt_BR/__init__.py
index 028637f2..01e33307 100644
--- a/faker/providers/ssn/pt_BR/__init__.py
+++ b/faker/providers/ssn/pt_BR/__init__.py
@@ -1,6 +1,7 @@
 # coding=utf-8
 
 from __future__ import unicode_literals
+
 from .. import Provider as SsnProvider
 
 
@@ -44,3 +45,22 @@ class Provider(SsnProvider):
     def cpf(self):
         c = self.ssn()
         return c[:3] + '.' + c[3:6] + '.' + c[6:9] + '-' + c[9:]
+
+    def rg(self):
+        """
+        Brazilian RG, return plain numbers.
+        Check:  https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html
+        """
+
+        digits = self.generator.random.sample(range(0, 9), 8)
+        checksum = sum(i * digits[i - 2] for i in range(2, 10))
+        last_digit = 11 - (checksum % 11)
+
+        if last_digit == 10:
+            digits.append('X')
+        elif last_digit == 11:
+            digits.append(0)
+        else:
+            digits.append(last_digit)
+
+        return ''.join(map(str, digits))


Test patch:
diff --git a/tests/providers/test_ssn.py b/tests/providers/test_ssn.py
index 0e09f3f8..1955ae60 100644
--- a/tests/providers/test_ssn.py
+++ b/tests/providers/test_ssn.py
@@ -423,6 +423,14 @@ class TestPtBR(unittest.TestCase):
         for _ in range(100):
             assert re.search(r'\d{3}\.\d{3}\.\d{3}-\d{2}', self.factory.cpf())
 
+    def test_pt_BR_rg(self):
+        for _ in range(100):
+            to_test = self.factory.rg()
+            if 'X' in to_test:
+                assert re.search(r'^\d{8}X', to_test)
+            else:
+                assert re.search(r'^\d{9}$', to_test)
+
 
 class TestNlNL(unittest.TestCase):
     def setUp(self):
Repository: joke2k/faker
Pull request #925 (2019-03-13 14:00:41)

implementation of months
### What does this changes

Brief summary of the changes

### What was wrong

Missing implementation of months for the date_time provider. 

### How this fixes it

Added implementation of months. Extra acronym added, ex: 5M = 5 months.




Patch:
diff --git a/faker/providers/date_time/__init__.py b/faker/providers/date_time/__init__.py
index 7158307a..8422a8f4 100644
--- a/faker/providers/date_time/__init__.py
+++ b/faker/providers/date_time/__init__.py
@@ -40,7 +40,7 @@ class ParseError(ValueError):
 
 
 timedelta_pattern = r''
-for name, sym in [('years', 'y'), ('weeks', 'w'), ('days', 'd'),
+for name, sym in [('years', 'y'), ('months', 'M'), ('weeks', 'w'), ('days', 'd'),
                   ('hours', 'h'), ('minutes', 'm'), ('seconds', 's')]:
     timedelta_pattern += r'((?P<{0}>(?:\+|-)\d+?){1})?'.format(name, sym)
 
@@ -1493,6 +1493,10 @@ class Provider(BaseProvider):
             if 'days' not in time_params:
                 time_params['days'] = 0
             time_params['days'] += 365.24 * time_params.pop('years')
+        if 'months' in time_params:
+            if 'days' not in time_params:
+                time_params['days'] = 0
+            time_params['days'] += 30.42 * time_params.pop('months')
 
         if not time_params:
             raise ParseError("Can't parse date string `{}`.".format(value))
diff --git a/setup.py b/setup.py
index 6cb08e43..2f3831a4 100644
--- a/setup.py
+++ b/setup.py
@@ -78,7 +78,7 @@ setup(
         "freezegun==0.3.11",
     ],
     extras_require={
-        ':python_version=="2.7"': [
+        ':python_version<"3.3"': [
             'ipaddress',
         ],
     },


Test patch:
diff --git a/tests/providers/test_date_time.py b/tests/providers/test_date_time.py
index 67c974cb..d8fc84f7 100644
--- a/tests/providers/test_date_time.py
+++ b/tests/providers/test_date_time.py
@@ -383,6 +383,16 @@ class TestDateTime(unittest.TestCase):
         assert isinstance(random_date, date)
         self.assertBetween(random_date, _30_years_ago, _20_years_ago)
 
+    def test_date_between_months(self):
+        today = date.today()
+        _2_months_ago = today - timedelta(days=2 * (365.24/12))
+        _9_months_ago = today - timedelta(days=9 * (365.24/12))
+
+        random_date = self.factory.date_between(start_date='-9M', end_date='-2M')
+
+        assert isinstance(random_date, date)
+        self.assertBetween(random_date, _9_months_ago, _2_months_ago)
+
     def test_parse_timedelta(self):
         from faker.providers.date_time import Provider
Repository: joke2k/faker
Pull request #940 (2019-04-13 11:57:46)

Accept step argument in random_int()
### What does this changes

Allows selecting a subset of integers in a range, for example even integers.

### What was wrong

Could not select a random even number with `pyint()`.

### How this fixes it

Accept step argument in random int

fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/__init__.py b/faker/providers/__init__.py
index e6e20d1c..d17efd28 100644
--- a/faker/providers/__init__.py
+++ b/faker/providers/__init__.py
@@ -93,15 +93,16 @@ class BaseProvider(object):
     def language_code(self):
         return self.random_element(BaseProvider.language_locale_codes.keys())
 
-    def random_int(self, min=0, max=9999):
+    def random_int(self, min=0, max=9999, step=1):
         """
         Returns a random integer between two values.
 
         :param min: lower bound value (inclusive; default=0)
         :param max: upper bound value (inclusive; default=9999)
+        :param step: range step (default=1)
         :returns: random integer between min and max
         """
-        return self.generator.random.randint(min, max)
+        return self.generator.random.randrange(min, max + 1, step)
 
     def random_digit(self):
         """
diff --git a/faker/providers/python/__init__.py b/faker/providers/python/__init__.py
index 8fa3f060..b86e61c5 100644
--- a/faker/providers/python/__init__.py
+++ b/faker/providers/python/__init__.py
@@ -70,8 +70,8 @@ class Provider(BaseProvider):
             self.random_number(right_digits),
         ))
 
-    def pyint(self, min=0, max=9999):
-        return self.generator.random_int(min, max)
+    def pyint(self, min=0, max=9999, step=1):
+        return self.generator.random_int(min, max,step=step)
 
     def pydecimal(self, left_digits=None, right_digits=None, positive=False,
                   min_value=None, max_value=None):


Test patch:
diff --git a/tests/providers/test_python.py b/tests/providers/test_python.py
index cc6308af..0d6443db 100644
--- a/tests/providers/test_python.py
+++ b/tests/providers/test_python.py
@@ -15,6 +15,10 @@ class TestPyint(unittest.TestCase):
     def test_pyint_bounds(self):
         self.assertTrue(0 <= self.factory.pyint() <= 9999)
 
+    def test_pyint_step(self):
+        random_int = self.factory.pyint(step=2)
+        self.assertEqual(0, random_int % 2)
+        
     def test_pyint_bound_0(self):
         self.assertEqual(0, self.factory.pyint(min=0, max=0))
Repository: joke2k/faker
Pull request #957 (2019-05-16 14:38:50)

Rename pyint min and max to min_value and max_value
### What does this changes

Rename `pyint`'s `min` and `max` arguments to `min_value` and `max_value`.

### What was wrong

Other generators `pyfloat` and `pydecimal` already name their arguments `min_value` and `max_value`, `pyint` should follow that convention.


fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/python/__init__.py b/faker/providers/python/__init__.py
index 6b8d4bcf..7b1bd6f8 100644
--- a/faker/providers/python/__init__.py
+++ b/faker/providers/python/__init__.py
@@ -71,8 +71,8 @@ class Provider(BaseProvider):
             self.random_number(right_digits),
         ))
 
-    def pyint(self, min=0, max=9999, step=1):
-        return self.generator.random_int(min, max, step=step)
+    def pyint(self, min_value=0, max_value=9999, step=1):
+        return self.generator.random_int(min_value, max_value, step=step)
 
     def pydecimal(self, left_digits=None, right_digits=None, positive=False,
                   min_value=None, max_value=None):


Test patch:
diff --git a/tests/providers/test_python.py b/tests/providers/test_python.py
index 4746a6de..d93628bd 100644
--- a/tests/providers/test_python.py
+++ b/tests/providers/test_python.py
@@ -20,16 +20,16 @@ class TestPyint(unittest.TestCase):
         self.assertEqual(0, random_int % 2)
 
     def test_pyint_bound_0(self):
-        self.assertEqual(0, self.factory.pyint(min=0, max=0))
+        self.assertEqual(0, self.factory.pyint(min_value=0, max_value=0))
 
     def test_pyint_bound_positive(self):
-        self.assertEqual(5, self.factory.pyint(min=5, max=5))
+        self.assertEqual(5, self.factory.pyint(min_value=5, max_value=5))
 
     def test_pyint_bound_negative(self):
-        self.assertEqual(-5, self.factory.pyint(min=-5, max=-5))
+        self.assertEqual(-5, self.factory.pyint(min_value=-5, max_value=-5))
 
     def test_pyint_range(self):
-        self.assertTrue(0 <= self.factory.pyint(min=0, max=2) <= 2)
+        self.assertTrue(0 <= self.factory.pyint(min_value=0, max_value=2) <= 2)
 
 
 class TestPyfloat(unittest.TestCase):