internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: joke2k/faker

Issue:
Faker should provide company VAT numbers
It would be nice if faker could provide company VAT numbers. More information about VAT codes is in Wikipedia: https://en.wikipedia.org/wiki/VAT_identification_number



Discussion:
VATs are very locale specific. We are going to rely on contributors to add locale-specific VAT providers.

Maybe you could submit a PR and be the first one :)


Resolving patch:
diff --git a/faker/providers/company/fi_FI/__init__.py b/faker/providers/company/fi_FI/__init__.py
--- a/faker/providers/company/fi_FI/__init__.py
+++ b/faker/providers/company/fi_FI/__init__.py
@@ -13,3 +13,41 @@ class Provider(CompanyProvider):
     company_suffixes = (
         'As Oy', 'Tmi', 'Oy', 'Oyj', 'Ky', 'Osk', 'ry'
     )
+
+    def company_business_id(self):
+        """
+        Returns Finnish company Business Identity Code (y-tunnus).
+        Format is 8 digits - e.g. FI99999999,[8] last digit is a check
+        digit utilizing MOD 11-2. The first digit is zero for some old
+        organizations. This function provides current codes starting with
+        non-zero.
+        """
+        def calculate_checksum(number):
+            """Calculate the checksum using mod 11,2 method"""
+            factors = [7, 9, 10, 5, 8, 4, 2]
+            sum = 0
+            for x, y in zip(number, factors):
+                sum = sum + int(x) * y
+            if sum % 11 == 0:
+                return '0'
+            else:
+                return str(11 - sum % 11)
+
+        first_digit = str(self.random_digit_not_null())
+        body = first_digit + self.bothify(self.random_element(('######',)))
+        cs = calculate_checksum(body)
+        return (body + '-' + str(cs))
+
+    def company_vat(self):
+        """
+        Returns Finnish VAT identification number (Arvonlisaveronumero).
+        This can be calculated from company business identity code by
+        adding prefix "FI" and removing dash before checksum.
+        """
+        def convert_to_vat(business_id):
+            """
+            Convert business id to VATIN
+            """
+            return 'FI' + business_id.replace('-', '')
+
+        return convert_to_vat(self.company_business_id())


Test patch:
Repository: joke2k/faker

Issue:
en_US SSN provider generates invalid SSNs
There's a few limitations on United States' SSNs that prevent it from being completely random.
- No group can be all 0s
- The SSN cannot start with 666
- The SSN cannot start with a number >= 900

See http://www.ssa.gov/employer/randomization.html

Could you modify the SSN generator to avoid these issues?



Discussion:
Hi Joe,

sorry I couldn't get to you sooner, I've been swamped at work.

I'll look soon into how fix this. If you can send a pull request in the meantime, it will help a ton.

Sure, I have a function that I'm using that should do the trick.  I'll send
it up as a PR.

On Wed, Jul 8, 2015 at 10:39 AM, Flavio Curella notifications@github.com
wrote:

> Hi Joe,
> 
> sorry I couldn't get to you sooner, I've been swamped at work.
> 
> I'll look soon into how fix this. If you can send a pull request in the
> meantime, it will help a ton.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/joke2k/faker/issues/260#issuecomment-119605287.


Resolving patch:
diff --git a/faker/providers/ssn/en_US/__init__.py b/faker/providers/ssn/en_US/__init__.py
--- a/faker/providers/ssn/en_US/__init__.py
+++ b/faker/providers/ssn/en_US/__init__.py
@@ -4,4 +4,17 @@
 
 
 class Provider(BaseProvider):
-    pass
+
+    @classmethod
+    def ssn(cls):
+        # Certain numbers are invalid for U.S. SSNs. The area (first 3 digits)
+        # cannot be 666 or 900-999. The group number (middle digits) cannot be
+        # 00. The serial (last 4 digits) cannot be 0000
+        area = BaseProvider.random_int(min=1, max=899)
+        if area == 666:
+            area += 1
+        group = BaseProvider.random_int(1, 99)
+        serial = BaseProvider.random_int(1, 9999)
+
+        ssn = "{0:03d}-{1:02d}-{2:04d}".format(area, group, serial)
+        return ssn


Test patch:
diff --git a/faker/tests/__init__.py b/faker/tests/__init__.py
--- a/faker/tests/__init__.py
+++ b/faker/tests/__init__.py
@@ -370,6 +370,19 @@ def test_no_words_paragraph(self):
         sentence = provider.sentence(0)
         self.assertEqual(sentence, '')
 
+    def test_us_ssn_valid(self):
+        from faker.providers.ssn.en_US import Provider
+
+        provider = Provider(None)
+        for i in range(1000):
+            ssn = provider.ssn()
+            self.assertEqual(len(ssn), 11)
+            self.assertNotEqual(ssn[0], '9')
+            self.assertNotEqual(ssn[0:3], '666')
+            self.assertNotEqual(ssn[0:3], '000')
+            self.assertNotEqual(ssn[4:6], '00')
+            self.assertNotEqual(ssn[7:11], '0000')
+
 
 class GeneratorTestCase(unittest.TestCase):
Repository: joke2k/faker

Issue:
use environment markers and reactivate universal wheels + distribute wheels
right now pip install  is broken due to the released package claiming to be universal wheel but not using environment markers

so pip makes a wheel for all pythons with the first python its run on, then its used on all other pythons,
so a pip install on python2.6 would create a broken wheel with the extra dependency which is then subsequently tried in other pythons, and will utterly break them



Discussion:
Hi @RonnyPfannschmidt ,

I'm going to look into this, but I'm not very well versed in wheels and packaging. Will you be available to review and test my PR?

yes

the simple solution would be not claiming to be a universal wheel,
the more complete solution would be to set up environment markers for the affected python versions

Thank you very much, I appreciate it.

I'm going to try using env markers, and if I can't get it to work, I'll give up on wheels for the moment.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,6 @@
 
 import os
 import io
-import sys
 from setuptools import setup, find_packages
 
 here = os.path.abspath(os.path.dirname(__file__))
@@ -13,11 +12,6 @@
 
 version = '0.5.3'
 
-install_requires = []
-if ((sys.version_info[0] == 2 and sys.version_info[1] < 7) or
-        (sys.version_info[0] == 3 and sys.version_info[1] < 1)):
-    install_requires.append('importlib')
-
 # this module can be zip-safe if the zipimporter implements iter_modules or if
 # pkgutil.iter_importer_modules has registered a dispatch for the zipimporter.
 try:
@@ -33,7 +27,9 @@
     version=version,
     description="Faker is a Python package that generates fake data for you.",
     long_description=README + '\n\n' + NEWS,
-    scripts=['faker/bin/faker'],
+    entry_points={
+        'console_scripts': ['faker=faker.cli:execute_from_command_line'],
+    },
     classifiers=[
         # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
         'Development Status :: 3 - Alpha',
@@ -57,5 +53,8 @@
     platforms=["any"],
     test_suite='faker.tests',
     zip_safe=zip_safe,
-    install_requires=install_requires
+    extras_require={
+        ':python_version=="2.6"': ['importlib'],
+        ':python_version=="3.0"': ['importlib'],
+    }
 )


Test patch:
Repository: joke2k/faker

Issue:
ReadTheDocs spacing is off for providers
http://fake-factory.readthedocs.org/en/latest/providers/internet.html

The spacing makes this pretty unreadable without constantly scrolling back and forth, which is annoying. 

Since these are the official extended docs linked to in the project ReadMe, it'd certainly be aesthetically nicer if they used native RTD formatting, for example see the formatting for the reference page of the factory boy project: http://factoryboy.readthedocs.org/en/latest/reference.html

I dug around a little trying to make a pull request to fix this, but it looks like Faker's docs are auto-generated somehow and I didn't have time to figure it all out. If you point me in the right direction, I'd be happy to submit a PR. 



Discussion:
Hi @jeffwidman ,

Thank you very much for offering your help, I really appreciate it.

You want to look into https://github.com/joke2k/faker/blob/master/faker/build_docs.py#L25-L57 . That's the method that writes the rst lines for a single provider.


Resolving patch:
diff --git a/faker/build_docs.py b/faker/build_docs.py
--- a/faker/build_docs.py
+++ b/faker/build_docs.py
@@ -41,20 +41,11 @@ def write_provider(fh, doc, provider, formatters, excludes=None):
         except UnicodeEncodeError:
             msg = 'error on "{0}" with value "{1}"'.format(signature, example)
             raise Exception(msg)
-        margin = max(30, doc.max_name_len+1)
-        remains = 150 - margin
-        separator = '#'
         write(fh, '\n')
-        for line in lines:
-            for i in range(0, (len(line) // remains) + 1):
-                write(fh, "\t{fake:<{margin}}{separator} {example}".format(
-                    fake=signature,
-                    separator=separator,
-                    example=line[i*remains:(i+1)*remains],
-                    margin=margin
-                ))
-                signature = separator = ' '
-    write(fh, '\n')
+        write(fh, "\t{fake}\n{example}\n".format(
+            fake=signature,
+            example='\n'.join(['\t# ' + line for line in lines]),
+        ))
 
 
 def write_docs(*args, **kwargs):


Test patch:
Repository: joke2k/faker

Issue:
Sex-specific names and Sex attribute don't match
While person distinguisheds between name_male() and name_female(), and profile generates a random ['sex'] attribute, these do not correlate at present. So in 50% of cases (ignoring neutral names like Chris) this results in F with male names and M with female names.



Discussion:

Resolving patch:
diff --git a/faker/providers/profile/__init__.py b/faker/providers/profile/__init__.py
--- a/faker/providers/profile/__init__.py
+++ b/faker/providers/profile/__init__.py
@@ -15,10 +15,15 @@ def simple_profile(self):
         Generates a basic profile with personal informations
         """
 
+        sex = self.random_element(["F", "M"])
+        if sex == 'F':
+            name = self.generator.name_female()
+        elif sex == 'M':
+            name = self.generator.name_male()
         return {
             "username": self.generator.user_name(),
-            "name": self.generator.name(),
-            "sex": self.random_element(["M", "F"]),
+            "name": name,
+            "sex": sex,
             "address": self.generator.address(),
             "mail": self.generator.free_email(),
 


Test patch:
Repository: joke2k/faker

Issue:
Fail to run the tests
Another problem I have when building the RPM is when I try to run the tests. This is in a minimal build environment, so maybe some library is missing. I have tried to use PYTHONPATH like in issue #291 but with no success.

Could you help me?

```
+ /usr/bin/python2 setup.py test
running test
running egg_info
writing requirements to fake_factory.egg-info/requires.txt
writing fake_factory.egg-info/PKG-INFO
writing top-level names to fake_factory.egg-info/top_level.txt
writing dependency_links to fake_factory.egg-info/dependency_links.txt
writing entry points to fake_factory.egg-info/entry_points.txt
reading manifest file 'fake_factory.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.md'
writing manifest file 'fake_factory.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 58, in <module>
    ':python_version=="3.0"': ['importlib'],
  File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 142, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 122, in with_project_on_sys_path
    func()
  File "/usr/lib/python2.7/site-packages/setuptools/command/test.py", line 163, in run_tests
    testRunner=self._resolve_as_ep(self.test_runner),
  File "/usr/lib64/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib64/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib64/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib64/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib64/python2.7/unittest/loader.py", line 100, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'tests'
```



Discussion:
My guess would be that `importlib` is not installed.

In addition to that, make you install the test requirements from  https://github.com/joke2k/faker/blob/master/faker/tests/requirements.txt


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,7 @@
     author_email='joke2k@gmail.com',
     url='http://github.com/joke2k/faker',
     license='MIT License',
-    packages=find_packages(exclude=['*.tests']),
+    packages=find_packages(),
     platforms=["any"],
     test_suite='faker.tests',
     zip_safe=zip_safe,


Test patch:
Repository: joke2k/faker

Issue:
Access to the Generator.random
It would be nice if one could gain access to the Generator.random variable so that one could save/set the state.  I realize I can pass in the seed, but one currently has no way of gathering what the seed/state is if using the automatically generated seed.  I don't want to use a fixed seed, but I do want to log/print the seed used _if_ the tests fail.

That is, I'd like to be able to do something like:  `faker.generator.getstate()` (which gets the random state w/o exposing random) or `faker.generator.random.getstate()` (which gives access to the random variable)

For now, the workaround appears to be to create a Faker object with your own Generator.



Discussion:
we could expose the `random` instance on the generator. Something like:

``` python
>>> from faker import Faker
>>> fake = Faker()
>>> fake.random
<random.Random at 0x7f992ca24e20>
>>> fake.random.getstate()
3,
 (2147483648L,
  3782733512L,
  2477412110L,
[...]
```


Resolving patch:
diff --git a/faker/generator.py b/faker/generator.py
--- a/faker/generator.py
+++ b/faker/generator.py
@@ -50,6 +50,10 @@ def get_providers(self):
         """Returns added providers."""
         return self.providers
 
+    @property
+    def random(self):
+        return random
+
     def seed(self, seed=None):
         """Calls random.seed"""
         random.seed(seed)


Test patch:
diff --git a/faker/tests/__init__.py b/faker/tests/__init__.py
--- a/faker/tests/__init__.py
+++ b/faker/tests/__init__.py
@@ -518,6 +518,12 @@ class GeneratorTestCase(unittest.TestCase):
     def setUp(self):
         self.generator = Generator()
 
+    @patch('random.getstate')
+    def test_get_random(self, mock_system_random):
+        random_instance = self.generator.random
+        random_instance.getstate()
+        self.assertFalse(mock_system_random.called)
+
     @patch('random.seed')
     def test_random_seed_doesnt_seed_system_random(self, mock_system_random):
         self.generator.seed(0)
Repository: joke2k/faker

Issue:
Add ability to generate lorem characters without punctuation
Sometimes I want to generate a string of characters of a specific length without any punctuation or capitalization but the lorem provider currently does not allow for this. 



Discussion:

Resolving patch:
diff --git a/faker/providers/lorem/__init__.py b/faker/providers/lorem/__init__.py
--- a/faker/providers/lorem/__init__.py
+++ b/faker/providers/lorem/__init__.py
@@ -8,7 +8,8 @@ class Provider(BaseProvider):
     @classmethod
     def word(cls):
         """
-        :example 'Lorem'
+        Generate a random word
+        :example 'lorem'
         """
         return cls.random_element(cls.word_list)
 
diff --git a/faker/providers/python/__init__.py b/faker/providers/python/__init__.py
--- a/faker/providers/python/__init__.py
+++ b/faker/providers/python/__init__.py
@@ -25,7 +25,7 @@ def pybool(cls):
 
     @classmethod
     def pystr(cls, max_chars=20):
-        return Lorem.text(max_chars)
+        return "".join(cls.random_letter() for i in range(max_chars))
 
     @classmethod
     def pyfloat(cls, left_digits=None, right_digits=None, positive=False):


Test patch:
diff --git a/faker/tests/__init__.py b/faker/tests/__init__.py
--- a/faker/tests/__init__.py
+++ b/faker/tests/__init__.py
@@ -499,6 +499,20 @@ def test_no_words_paragraph(self):
         sentence = provider.sentence(0)
         self.assertEqual(sentence, '')
 
+    def test_random_pystr_characters(self):
+        from faker.providers.python import Provider
+        provider = Provider(None)
+
+        characters = provider.pystr()
+        self.assertEqual(len(characters), 20)
+        characters = provider.pystr(max_chars=255)
+        self.assertEqual(len(characters), 255)
+        characters = provider.pystr(max_chars=0)
+        self.assertEqual(characters, '')
+        characters = provider.pystr(max_chars=-10)
+        self.assertEqual(characters, '')
+
+
     def test_us_ssn_valid(self):
         from faker.providers.ssn.en_US import Provider
Repository: joke2k/faker

Issue:
faker dk_DK person provider data contains leading whitespaces



Discussion:

Resolving patch:
diff --git a/faker/providers/person/dk_DK/__init__.py b/faker/providers/person/dk_DK/__init__.py
--- a/faker/providers/person/dk_DK/__init__.py
+++ b/faker/providers/person/dk_DK/__init__.py
@@ -104,12 +104,12 @@ class Provider(PersonProvider):
         'Sørensen', 'Rasmussen', 'Petersen', 'Jørgensen', 'Madsen', 'Kristensen', 'Olsen',
         'Christiansen', 'Thomsen', 'Poulsen', 'Johansen', 'Knudsen', 'Mortensen', 'Møller',
         'Jacobsen', 'Jakobsen', 'Olesen', 'Frederiksen', 'Mikkelsen', 'Henriksen', 'Laursen',
-        'Lund', 'Schmidt', 'Eriksen', 'Holm', '	Kristiansen', 'Clausen', 'Simonsen',
+        'Lund', 'Schmidt', 'Eriksen', 'Holm', 'Kristiansen', 'Clausen', 'Simonsen',
         'Svendsen', 'Andreasen', 'Iversen', 'Jeppesen', 'Mogensen', 'Jespersen', 'Nissen',
         'Lauridsen', 'Frandsen', 'Østergaard', 'Jepsen', 'Kjær', 'Carlsen', 'Vestergaard',
         'Jessen', 'Nørgaard', 'Dahl', 'Christoffersen', 'Skov', 'Søndergaard', 'Bertelsen',
         'Bruun', 'Lassen', 'Bach', 'Gregersen', 'Friis', 'Johnsen', 'Steffensen',
-        'Kjeldsen', 'Bech', 'Krogh', '	Lauritsen', 'Danielsen', 'Mathiesen', 'Andresen',
+        'Kjeldsen', 'Bech', 'Krogh', 'Lauritsen', 'Danielsen', 'Mathiesen', 'Andresen',
         'Brandt', 'Winther', 'Toft', 'Ravn', 'Mathiasen', 'Dam', 'Holst',
         'Nilsson', 'Lind', 'Berg', 'Schou', 'Overgaard', 'Kristoffersen', 'Schultz',
         'Klausen', 'Karlsen', 'Paulsen', 'Hermansen', 'Thorsen', 'Koch', 'Thygesen',


Test patch:
Repository: joke2k/faker

Issue:
Published packages include docs/ as a module
The published wheel and sdist on PyPI for at least version 0.7.5 include `docs/__init__.py` as a top-level module in addition to `faker`. This conflicts with some other packages we use (PyICU) and seems like bad package hygiene, especially since the `docs` dir in this repository is definitely not a module. My guess is that a `__init__.py` made it in there on the maintainer's machine before running `setup.py` and it was erroneously discovered as a module.

We're going to republish the package to our own internal repository, but I think it would help the community to `git clean` as necessary and re-publish a new version, and consider adding necessary exclusions to the `setup.py` or `MANIFEST.in`.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@
     author_email='joke2k@gmail.com',
     url='https://github.com/joke2k/faker',
     license='MIT License',
-    packages=find_packages(),
+    packages=find_packages(exclude=("docs",)),
     platforms=["any"],
     test_suite='faker.tests',
     zip_safe=zip_safe,


Test patch:
Repository: joke2k/faker

Issue:
Add a file path provider
In the file providers would be nice to have a file_path provider who would return a path like ```/lorem/ipsum/lorem.pdf```.


Discussion:

Resolving patch:
diff --git a/faker/providers/file/__init__.py b/faker/providers/file/__init__.py
--- a/faker/providers/file/__init__.py
+++ b/faker/providers/file/__init__.py
@@ -201,3 +201,16 @@ def file_extension(cls, category=None):
         """
         category = category if category else cls.random_element(list(cls.file_extensions.keys()))
         return cls.random_element(cls.file_extensions[category])
+
+    @classmethod
+    def file_path(cls, depth=1, category=None, extension=None):
+        """
+        :param category: audio|image|office|text|video
+        :param extension: file extension
+        :param depth: depth of the file (depth >= 0)
+        """
+        file = Provider.file_name(category, extension)
+        path = "/{0}".format(file)
+        for d in range(0, depth):
+            path = "/{0}{1}".format(WordProvider.word(), path)
+        return path


Test patch:
diff --git a/tests/providers/file.py b/tests/providers/file.py
new file mode 100644
--- /dev/null
+++ b/tests/providers/file.py
@@ -0,0 +1,25 @@
+from __future__ import unicode_literals
+
+import unittest
+import re
+
+from faker import Factory
+from faker.providers.file import Provider as FileProvider
+
+
+class TestFile(unittest.TestCase):
+    """ Tests file """
+
+    def setUp(self):
+        self.factory = Factory.create()
+
+    def test_file_path(self):
+        for _ in range(100):
+            file_path = FileProvider.file_path()
+            self.assertTrue(re.search(r'\/\w+\/\w+\.\w+', file_path))
+            file_path = FileProvider.file_path(depth=3)
+            self.assertTrue(re.search(r'\/\w+\/\w+\/\w+\.\w+', file_path))
+            file_path = FileProvider.file_path(extension='pdf')
+            self.assertTrue(re.search(r'\/\w+\/\w+\.pdf', file_path))
+            file_path = FileProvider.file_path(category='image')
+            self.assertTrue(re.search(r'\/\w+\/\w+\.(bmp|gif|jpeg|jpg|png|tiff)', file_path))
Repository: joke2k/faker

Issue:
Using É, é (e-acute)  in emails.
It looks that É, é (e-acute) symbols are not appropriate for valid email. I used https://pypi.python.org/pypi/robotframework-faker/ which uses this library and the following email was returned: 
andré38@mentzel.net

But email verification was failed for this email. 
Could you remove É, é and other such letters if they are present from valid email generation?


Discussion:
Thanks for the report @Bergil32 .

What version of faker are you using and what locale is having this problem?
robotframework-faker 4.0.0 that uses Faker 0.7.11
It was detected for de_DE locale.
The `É` and the `é` are missing from https://github.com/joke2k/faker/blob/master/faker/providers/internet/de_DE/__init__.py#L14

@Bergil32 Can you submit a PR with the appropriate replacements?

Resolving patch:
diff --git a/faker/providers/internet/de_DE/__init__.py b/faker/providers/internet/de_DE/__init__.py
--- a/faker/providers/internet/de_DE/__init__.py
+++ b/faker/providers/internet/de_DE/__init__.py
@@ -15,5 +15,7 @@ class Provider(InternetProvider):
         ('ä', 'ae'), ('Ä', 'Ae'),
         ('ö', 'oe'), ('Ö', 'Oe'),
         ('ü', 'ue'), ('Ü', 'Ue'),
+        ('é', 'e'), ('É', 'E'),
+        ('à', 'a'), ('À', 'A'),
         ('ß', 'ss'),
     )


Test patch: