Repository: joke2k/faker
Pull request #1589 (2022-01-04 11:30:05)

added banks for fa-ir
### What does this changes

added banks for fa_IR locale



Patch:
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index bf029fc8..21c57df3 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 11.1.0
+current_version = 11.2.0
 files = VERSION faker/__init__.py docs/conf.py
 commit = True
 tag = True
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b3590fd0..e7ec5fa0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 ## Changelog
 
+### [v11.2.0 - 2022-01-05](https://github.com/joke2k/faker/compare/v11.1.0...v11.2.0)
+
+* Improve phone numbers for `it_IT`. Thanks @FrancYescO.
+
 ### [v11.1.0 - 2021-12-28](https://github.com/joke2k/faker/compare/v11.0.0...v11.1.0)
 
 * Add providers for `az_AZ` locale. Thanks @sevdimali.
diff --git a/VERSION b/VERSION
index 68d8f15e..b85c6c7b 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-11.1.0
+11.2.0
diff --git a/docs/conf.py b/docs/conf.py
index 47a0a441..9007a231 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -51,9 +51,9 @@ copyright = "2014, Daniele Faraglia"
 # built documents.
 #
 # The short X.Y version.
-version = "11.1.0"
+version = "11.2.0"
 # The full version, including alpha/beta/rc tags.
-release = "11.1.0"
+release = "11.2.0"
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/faker/__init__.py b/faker/__init__.py
index 027e1b16..07acc9e7 100644
--- a/faker/__init__.py
+++ b/faker/__init__.py
@@ -2,6 +2,6 @@ from faker.factory import Factory
 from faker.generator import Generator
 from faker.proxy import Faker
 
-VERSION = "11.1.0"
+VERSION = "11.2.0"
 
 __all__ = ("Factory", "Generator", "Faker")
diff --git a/faker/providers/bank/fa_IR/__init__.py b/faker/providers/bank/fa_IR/__init__.py
new file mode 100644
index 00000000..5e23d29f
--- /dev/null
+++ b/faker/providers/bank/fa_IR/__init__.py
@@ -0,0 +1,60 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    """Implement bank provider for ``fa_IR`` locale."""
+
+    bban_format = "IR########################"
+    country_code = "IR"
+    swift_bank_codes = (
+        "BEGN",
+        "KESH",
+        "BKMN",
+        "BKBP",
+        "CIYB",
+        "BTOS",
+        "IVBB",
+        "KBID",
+        "KIBO",
+        "KHMI",
+    )
+    swift_location_codes = ("TH",)
+    swift_branch_codes = ("BSH", "BCQ", "tIR", "tTH", "ATM", "BIC", "TIR", "ASR", "FOR")
+
+    banks = (
+        "بانکهای قرض الحسنه",
+        "بانک ملّی ایران",
+        "بانک اقتصاد نوین",
+        "بانک قرض‌الحسنه مهر ایران",
+        "بانک سپه",
+        "بانک پارسیان",
+        "بانک قرض‌الحسنه رسالت",
+        "بانک صنعت و معدن",
+        "بانک کارآفرین",
+        "بانک کشاورزی",
+        "بانک سامان",
+        "بانک مسکن",
+        "بانک سینا",
+        "بانک توسعه صادرات ایران",
+        "بانک خاور میانه",
+        "بانک توسعه تعاون",
+        "بانک شهر",
+        "پست بانک ایران",
+        "بانک دی",
+        "بانک صادرات",
+        "بانک ملت",
+        "بانک تجارت",
+        "بانک رفاه",
+        "بانک حکمت ایرانیان",
+        "بانک گردشگری",
+        "بانک ایران زمین",
+        "بانک قوامین",
+        "بانک انصار",
+        "بانک سرمایه",
+        "بانک پاسارگاد",
+        "بانک مشترک ایران-ونزوئلا",
+    )
+
+    def bank(self) -> str:
+        """Generate a bank name."""
+        return self.random_element(self.banks)
diff --git a/faker/providers/phone_number/it_IT/__init__.py b/faker/providers/phone_number/it_IT/__init__.py
index a7cb3821..9d3bfdd6 100644
--- a/faker/providers/phone_number/it_IT/__init__.py
+++ b/faker/providers/phone_number/it_IT/__init__.py
@@ -3,11 +3,268 @@ from .. import Provider as PhoneNumberProvider
 
 class Provider(PhoneNumberProvider):
     formats = (
-        "+39 ### ## ## ####",
-        "+39 ## #######",
-        "+39 ## ########",
-        "+39 ### #######",
-        "+39 ### ########",
-        "+39 #### #######",
-        "+39 #### ########",
+        "+39 {{area_code}}#####!!",
+        "{{area_code}}#####!!",
     )
+
+    area_codes = (
+        # Landline: https://en.wikipedia.org/wiki/List_of_dialling_codes_in_Italy
+        "010#",
+        "011#",
+        "0122",
+        "0123",
+        "0124",
+        "0125",
+        "0131",
+        "0141",
+        "015#",
+        "0161",
+        "0163",
+        "0165",
+        "0166",
+        "0171",
+        "0183",
+        "0184",
+        "0185",
+        "0187",
+        "019#",
+        "02##",
+        "030#",
+        "031#",
+        "0321",
+        "0322",
+        "0324",
+        "0331",
+        "0332",
+        "0341",
+        "0342",
+        "0343",
+        "0344",
+        "0345",
+        "035#",
+        "0362",
+        "0363",
+        "0364",
+        "0365",
+        "0371",
+        "0372",
+        "0373",
+        "0375",
+        "0376",
+        "0382",
+        "039#",
+        "040#",
+        "041#",
+        "0421",
+        "0422",
+        "0423",
+        "0424",
+        "0425",
+        "0426",
+        "0429",
+        "0431",
+        "0432",
+        "0434",
+        "0438",
+        "0444",
+        "0445",
+        "045#",
+        "0461",
+        "0471",
+        "0481",
+        "049#",
+        "050#",
+        "051#",
+        "0521",
+        "0522",
+        "0523",
+        "0532",
+        "0535",
+        "0536",
+        "0541",
+        "0543",
+        "0544",
+        "0545",
+        "0547",
+        "0549",
+        "055#",
+        "0564",
+        "0565",
+        "0566",
+        "0571",
+        "0572",
+        "0573",
+        "0574",
+        "0575",
+        "0577",
+        "0578",
+        "0583",
+        "0584",
+        "0585",
+        "0586",
+        "0587",
+        "0588",
+        "059#",
+        "06##",
+        "070#",
+        "071#",
+        "0721",
+        "0731",
+        "0732",
+        "0733",
+        "0734",
+        "0735",
+        "0736",
+        "0737",
+        "075#",
+        "0761",
+        "0765",
+        "0771",
+        "0773",
+        "0774",
+        "0775",
+        "0776",
+        "0782",
+        "0783",
+        "0784",
+        "0789",
+        "079#",
+        "080#",
+        "081#",
+        "0823",
+        "0824",
+        "0825",
+        "0832",
+        "085#",
+        "0861",
+        "0862",
+        "0865",
+        "0874",
+        "0881",
+        "0882",
+        "0883",
+        "0884",
+        "089#",
+        "0835",
+        "090#",
+        "091#",
+        "0921",
+        "0931",
+        "0932",
+        "0933",
+        "0923",
+        "0922",
+        "0925",
+        "0934",
+        "0941",
+        "0942",
+        "095#",
+        "0961",
+        "0962",
+        "0963",
+        "0965",
+        "0974",
+        "0975",
+        "099#",
+        "0984",
+        # Mobile: https://it.wikipedia.org/wiki/Prefissi_telefonici_dei_cellulari_italiani
+        "3513",
+        "3514",
+        "3515",
+        "3516",
+        "3517",
+        "3518",
+        "3519",
+        "3520",
+        "330#",
+        "331#",
+        "333#",
+        "334#",
+        "335#",
+        "336#",
+        "337#",
+        "338#",
+        "339#",
+        "360#",
+        "361#",
+        "362#",
+        "363#",
+        "366#",
+        "368#",
+        "381#",
+        "385#",
+        "340#",
+        "341#",
+        "342#",
+        "343#",
+        "344#",
+        "345#",
+        "346#",
+        "347#",
+        "348#",
+        "349#",
+        "383#",
+        "320#",
+        "322#",
+        "323#",
+        "324#",
+        "327#",
+        "328#",
+        "329#",
+        "355#",
+        "380#",
+        "388#",
+        "389#",
+        "390#",
+        "391#",
+        "392#",
+        "393#",
+        "397#",
+        "3773",
+        "3793",
+        "3710",
+        "3777",
+        "3311",
+        "3703",
+        "3534",
+        "3778",
+        "3533",
+        "373#",
+        "3755",
+        "3756",
+        "3757",
+        "3770",
+        "3791",
+        "3792",
+        "3500",
+        "3501",
+        "3505",
+        "3509",
+        "3510",
+        "3511",
+        "3512",
+        "373#",
+        "382#",
+        "3780",
+        "3500",
+        "3505",
+        "3760",
+        "3711",
+        "3713",
+        "3714",
+        "3715",
+        "3716",
+        "3772",
+        "3774",
+        "3776",
+        "3779",
+        "3701",
+        "3783",
+    )
+
+    def area_code(self) -> str:
+        return self.numerify(self.random_element(self.area_codes))
+
+    def phone_number(self) -> str:
+        pattern: str = self.random_element(self.formats)
+        return self.numerify(self.generator.parse(pattern))


Test patch:
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
index 9c5df7e9..bfa3532f 100644
--- a/tests/providers/test_bank.py
+++ b/tests/providers/test_bank.py
@@ -69,6 +69,18 @@ class TestNoNo:
             assert re.fullmatch(r"\d{2}\d{11}", iban[2:])
 
 
+class TestFaIr:
+    """Test fa_IR bank provider"""
+
+    def test_bban(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r"IR\d{24}", faker.bban())
+
+    def test_bank(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.match(r"\D{7,25}", faker.bank())
+
+
 class TestFiFi:
     """Test fi_FI bank provider"""