nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: joke2k/faker
Pull request #998 (2019-09-26 13:36:30)

fix randomize_nb_elements max param
### What does this changes
The `max` argument for randomize_nb_elements is undocumented (and only the min is every used internally)....but it does exist and is broken :)

### What was wrong

Tiny typo/copy-paste error, `> min` instead of `>max`


fcurella: Nice Catch! Thank you! ✨ 

Patch:
diff --git a/faker/providers/__init__.py b/faker/providers/__init__.py
index 4ef04937..9bb9f47b 100644
--- a/faker/providers/__init__.py
+++ b/faker/providers/__init__.py
@@ -284,7 +284,7 @@ class BaseProvider(object):
         nb = int(number * self.generator.random.randint(_min, _max) / 100)
         if min is not None and nb < min:
             nb = min
-        if max is not None and nb > min:
+        if max is not None and nb > max:
             nb = max
         return nb
 


Test patch:
diff --git a/tests/providers/__init__.py b/tests/providers/__init__.py
index 857fa7ce..7e6410c5 100644
--- a/tests/providers/__init__.py
+++ b/tests/providers/__init__.py
@@ -30,6 +30,9 @@ class BaseProviderTestCase(unittest.TestCase):
 
         assert self.provider.randomize_nb_elements(le=True, ge=True) == 10
 
+        assert self.provider.randomize_nb_elements(min=42) == 42
+        assert self.provider.randomize_nb_elements(max=1) == 1
+
         number = 9999
         random_times = 100
         lower_bound = int(number * 0.6)
Repository: joke2k/faker
Pull request #1009 (2019-10-07 23:47:20)

Fixed PR #1008 
### What does this changes

Added missing blank line

### What was wrong

\-

### How this fixes it

\-

Fixes #
PR #1008 


rubenandre: Coverage decreased because other file outside the scope of this pull request
fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/automotive/pt_PT/__init__.py b/faker/providers/automotive/pt_PT/__init__.py
new file mode 100644
index 00000000..5439e1ac
--- /dev/null
+++ b/faker/providers/automotive/pt_PT/__init__.py
@@ -0,0 +1,14 @@
+# coding=utf-8
+from __future__ import unicode_literals
+
+from .. import Provider as AutomotiveProvider
+
+
+class Provider(AutomotiveProvider):
+
+    # From: https://pt.wikipedia.org/wiki/Matr%C3%ADculas_de_autom%C3%B3veis_em_Portugal
+    license_formats = (
+        '##-##-??',
+        '##-??-##',
+        '??-##-##',
+    )


Test patch:
diff --git a/tests/providers/test_automotive.py b/tests/providers/test_automotive.py
index 20f3c39e..6560694e 100644
--- a/tests/providers/test_automotive.py
+++ b/tests/providers/test_automotive.py
@@ -20,6 +20,17 @@ class TestPtBR(unittest.TestCase):
         assert self.format.match(plate), "%s is not in the correct format." % plate
 
 
+class TestPtPT(unittest.TestCase):
+
+    def setUp(self):
+        self.factory = Faker('pt_PT')
+        self.pattern = re.compile(r'^\d{2}-\d{2}-[aA-zZ]{2}$|^\d{2}-[aA-zZ]{2}-\d{2}$|^[aA-zZ]{2}-\d{2}-\d{2}$')
+
+    def test_pt_PT_plate_format(self):
+        plate = self.factory.license_plate()
+        assert self.pattern.match(plate), "%s is not in the correct format." % plate
+
+
 class TestHuHU(unittest.TestCase):
 
     def setUp(self):
Repository: joke2k/faker
Pull request #1136 (2020-03-19 13:19:56)

Add dga by date
### What does this changes

Add Domain Generator Algorithm by date method and test for it



fcurella: Good idea! Thank you!

Patch:
diff --git a/faker/providers/internet/__init__.py b/faker/providers/internet/__init__.py
index 60dab824..e42ff0bd 100644
--- a/faker/providers/internet/__init__.py
+++ b/faker/providers/internet/__init__.py
@@ -222,6 +222,33 @@ class Provider(BaseProvider):
         company = self._to_ascii(company_elements.pop(0))
         return company
 
+    def dga(self, year=None, month=None, day=None, tld=None, length=None):
+        """Generates a domain name by given date
+        https://en.wikipedia.org/wiki/Domain_generation_algorithm
+
+        :type year: int
+        :type month: int
+        :type day: int
+        :type tld: str
+        :type length: int
+        :rtype: str
+        """
+
+        domain = ''
+        year = year or self.random_int(min=1, max=9999)
+        month = month or self.random_int(min=1, max=12)
+        day = day or self.random_int(min=1, max=30)
+        tld = tld or self.tld()
+        length = length or self.random_int(min=2, max=63)
+
+        for _ in range(length):
+            year = ((year ^ 8 * year) >> 11) ^ ((year & 0xFFFFFFF0) << 17)
+            month = ((month ^ 4 * month) >> 25) ^ 16 * (month & 0xFFFFFFF8)
+            day = ((day ^ (day << 13)) >> 19) ^ ((day & 0xFFFFFFFE) << 12)
+            domain += chr(((year ^ month ^ day) % 25) + 97)
+
+        return domain + '.' + tld
+
     def tld(self):
         return self.random_element(self.tlds)
 


Test patch:
diff --git a/tests/test_factory.py b/tests/test_factory.py
index a93df7cf..9ba55204 100644
--- a/tests/test_factory.py
+++ b/tests/test_factory.py
@@ -889,6 +889,14 @@ class FactoryTestCase(unittest.TestCase):
 
         assert expected_methods == sorted(got_methods)
 
+    def test_dga(self):
+        faker = Faker()
+
+        assert faker.dga() != faker.dga()
+
+        expected_domain = 'cqphixmpdfpptskr.com'
+        assert faker.dga(day=1, month=1, year=1000, tld='com', length=16) == expected_domain
+
     def test_random_sample_unique(self):
         from faker.providers import BaseProvider
         provider = BaseProvider(self.generator)
Repository: joke2k/faker
Pull request #1189 (2020-05-29 15:11:18)

Adding .uk email providers and TLDs.
Adds some British free email providers and TLDs.

Data taken from https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/en_GB/Internet.php


Patch:
diff --git a/faker/providers/company/hy_AM/__init__.py b/faker/providers/company/hy_AM/__init__.py
index fcdb1052..e5edac78 100644
--- a/faker/providers/company/hy_AM/__init__.py
+++ b/faker/providers/company/hy_AM/__init__.py
@@ -5,7 +5,7 @@ class Provider(CompanyProvider):
 
     formats = (
         '{{first_name}} և {{first_name}} {{company_suffix}}',
-        '{{last_name} {{company_suffix}}',
+        '{{last_name}} {{company_suffix}}',
         '{{last_name}} և {{last_name}} {{company_suffix}}'
         '{{last_name}}, {{last_name}} և {{last_name}} {{company_suffix}}',
     )
diff --git a/faker/providers/internet/en_GB/__init__.py b/faker/providers/internet/en_GB/__init__.py
new file mode 100644
index 00000000..c2b795ed
--- /dev/null
+++ b/faker/providers/internet/en_GB/__init__.py
@@ -0,0 +1,17 @@
+from .. import Provider as InternetProvider
+
+
+class Provider(InternetProvider):
+    # Data taken from
+    # https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/en_GB/Internet.php
+
+    free_email_domains = (
+        'gmail.com',
+        'yahoo.com',
+        'hotmail.com',
+        'gmail.co.uk',
+        'yahoo.co.uk',
+        'hotmail.co.uk',
+    )
+
+    tlds = ('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org', 'co.uk')


Test patch:
diff --git a/tests/providers/test_internet.py b/tests/providers/test_internet.py
index 30337171..cf5e751c 100644
--- a/tests/providers/test_internet.py
+++ b/tests/providers/test_internet.py
@@ -7,6 +7,7 @@ from unittest.mock import PropertyMock, patch
 import pytest
 
 from faker.providers.internet import Provider as InternetProvider
+from faker.providers.internet.en_GB import Provider as EnGbInternetProvider
 from faker.providers.internet.pl_PL import Provider as PlPlInternetProvider
 from faker.providers.internet.zh_CN import Provider as ZhCnInternetProvider
 from faker.providers.person.ja_JP import Provider as JaPersonProvider
@@ -616,3 +617,15 @@ class TestFilPh(TestEnPh):
 class TestTlPh(TestFilPh):
     """Test tl_PH internet provider methods"""
     pass
+
+
+class TestEnGb:
+    """Tests for the en_GB locale."""
+
+    def test_free_email_domain(self, faker):
+        domain = faker.free_email_domain()
+        assert domain in EnGbInternetProvider.free_email_domains
+
+    def test_tld(self, faker):
+        tld = faker.tld()
+        assert tld in EnGbInternetProvider.tlds
Repository: joke2k/faker
Pull request #1203 (2020-06-16 18:55:28)

Add es_ES internet provider.
### What does this changes

Add `es_ES` internet provider.


malefice: @fcurella, this PR seems to be OK for merging. Do you have additional changes you want in the PR?
fcurella: LGTM. Thank you  @mondeja and thank you so much for triaging, @malefice :)

Patch:
diff --git a/faker/providers/internet/es_ES/__init__.py b/faker/providers/internet/es_ES/__init__.py
new file mode 100644
index 00000000..0a9513e2
--- /dev/null
+++ b/faker/providers/internet/es_ES/__init__.py
@@ -0,0 +1,14 @@
+from .. import Provider as InternetProvider
+
+
+class Provider(InternetProvider):
+    safe_email_tlds = ('com', 'net', 'es', 'es')
+    tlds = ('com', 'com', 'com', 'net', 'org', 'es', 'es', 'es')
+    replacements = (
+        ('à', 'a'), ('â', 'a'), ('ã', 'a'), ('á', 'a'),
+        ('ç', 'c'),
+        ('é', 'e'), ('ê', 'e'),
+        ('í', 'i'),
+        ('ô', 'o'), ('ö', 'o'), ('õ', 'o'), ('ó', 'o'),
+        ('ú', 'u'),
+    )


Test patch:
diff --git a/tests/providers/test_internet.py b/tests/providers/test_internet.py
index 65574da4..9c025eae 100644
--- a/tests/providers/test_internet.py
+++ b/tests/providers/test_internet.py
@@ -11,6 +11,7 @@ from validators import email as validate_email
 
 from faker.providers.internet import Provider as InternetProvider
 from faker.providers.internet.en_GB import Provider as EnGbInternetProvider
+from faker.providers.internet.es_ES import Provider as EsEsInternetProvider
 from faker.providers.internet.pl_PL import Provider as PlPlInternetProvider
 from faker.providers.internet.zh_CN import Provider as ZhCnInternetProvider
 from faker.providers.person.ja_JP import Provider as JaPersonProvider
@@ -642,3 +643,11 @@ class TestEnGb:
     def test_tld(self, faker):
         tld = faker.tld()
         assert tld in EnGbInternetProvider.tlds
+
+
+class TestEsEs:
+    """Tests for the es_ES locale."""
+
+    def test_tld(self, faker):
+        tld = faker.tld()
+        assert tld in EsEsInternetProvider.tlds
Repository: joke2k/faker
Pull request #1241 (2020-08-11 08:35:07)

Improve proxy initialization as list type error.
### What does this changes

When `Faker` class is initialized as list with values that are not strings, a better exception is raised. 

### Actual behaviour

```python
>>> from faker import Faker
>>> Faker([1, 2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../faker/faker/proxy.py", line 33, in __init__
    assert all(isinstance(local_code, str) for local_code in locale)
AssertionError
```

### Behaviour after this pull

```python
>>> from faker import Faker
>>> Faker([1, 2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../faker/faker/proxy.py", line 36, in __init__
    raise TypeError('The locale "%s" must be a string.' % str(code))
TypeError: The locale "1" must be a string.
```


fcurella: Thank you!

Patch:
diff --git a/faker/proxy.py b/faker/proxy.py
index cb64f647..67f261ef 100644
--- a/faker/proxy.py
+++ b/faker/proxy.py
@@ -30,9 +30,10 @@ class Faker:
         # This guarantees a FIFO ordering of elements in `locales` based on the final
         # locale string while discarding duplicates after processing
         elif isinstance(locale, (list, tuple, set)):
-            assert all(isinstance(local_code, str) for local_code in locale)
             locales = []
             for code in locale:
+                if not isinstance(code, str):
+                    raise TypeError('The locale "%s" must be a string.' % str(code))
                 final_locale = code.replace('-', '_')
                 if final_locale not in locales:
                     locales.append(final_locale)


Test patch:
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
index a565f0d8..2b48d2bf 100644
--- a/tests/test_proxy.py
+++ b/tests/test_proxy.py
@@ -37,6 +37,12 @@ class TestFakerProxyClass:
         assert fake.locales == expected
         assert len(fake.factories) == len(expected)
 
+    def test_locale_as_list_invalid_value_type(self):
+        locale = [1, 2]
+        with pytest.raises(TypeError) as exc:
+            Faker(locale)
+        assert str(exc.value) == 'The locale "1" must be a string.'
+
     def test_locale_as_ordereddict(self):
         locale = OrderedDict([
             ('de_DE', 3),
Repository: joke2k/faker
Pull request #1276 (2020-09-26 17:42:54)

Added bank provider for tr_TR locale.
Added bank provider for tr_TR locale. 👍  #1200

malefice: This looks OK for merging. @fcurella, do you have anything else that you want to be added?
fcurella: Looks good to me! Thanks @iamnotagentleman and thanks @malefice for triaging!

Patch:
diff --git a/faker/providers/bank/tr_TR/__init__.py b/faker/providers/bank/tr_TR/__init__.py
new file mode 100644
index 00000000..e89db54f
--- /dev/null
+++ b/faker/providers/bank/tr_TR/__init__.py
@@ -0,0 +1,8 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    """Implement bank provider for ``tr_TR`` locale."""
+
+    bban_format = '######################'
+    country_code = 'TR'


Test patch:
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
index 46f710ec..2ce36aff 100644
--- a/tests/providers/test_bank.py
+++ b/tests/providers/test_bank.py
@@ -11,6 +11,7 @@ from faker.providers.bank.fr_FR import Provider as FrFrBankProvider
 from faker.providers.bank.no_NO import Provider as NoNoBankProvider
 from faker.providers.bank.pl_PL import Provider as PlPlBankProvider
 from faker.providers.bank.pt_PT import Provider as PtPtBankProvider
+from faker.providers.bank.tr_TR import Provider as TrTrBankProvider
 
 
 def is_valid_iban(iban):
@@ -191,3 +192,18 @@ class TestFilPh(TestEnPh):
 class TestTlPh(TestEnPh):
     """Test tl_PH bank provider"""
     pass
+
+
+class TestTrTr:
+    """Test tr_TR bank provider"""
+
+    def test_bban(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r"\d{22}", faker.bban())
+
+    def test_iban(self, faker, num_samples):
+        for _ in range(num_samples):
+            iban = faker.iban()
+            assert is_valid_iban(iban)
+            assert iban[:2] == TrTrBankProvider.country_code
+            assert re.fullmatch(r"\d{2}\d{22}", iban[2:])