Skip to content

Commit 430aa3b

Browse files
authored
Merge pull request #44 from aj3sh/formatting
Code formatting and updated pre-commit hook
2 parents 6fe2b32 + 662f10d commit 430aa3b

File tree

7 files changed

+38
-23
lines changed

7 files changed

+38
-23
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
# stop the build if there are Python syntax errors or undefined names
3636
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3737
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
39-
38+
flake8 . --count --exit-zero --max-complexity=10 --ignore=E203,W503 --max-line-length=127 --statistics
39+
# For the reason behind ignoring E203 and W503, visit https://blackq.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
4040
- name: Run tests
4141
run: |
4242
coverage run -m unittest discover nepali/tests -v

.pre-commit-config.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
44
hooks:
5-
- id: end-of-file-fixer
6-
- id: trailing-whitespace
7-
- repo: https://github.com/psf/black
8-
rev: 22.10.0
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- repo: https://github.com/akaihola/darker
8+
rev: 1.7.1
99
hooks:
10-
- id: black
10+
- id: darker
11+
args:
12+
- --isort
13+
- --lint=flake8 --max-line-length=88
14+
additional_dependencies:
15+
- isort==5.11.5
16+
- flake8==5.0.4

nepali/number/_nepalinumber.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __convert_or_return(self, obj) -> Union["nepalinumber", object]:
126126
"""
127127
try:
128128
return nepalinumber(obj)
129-
except (TypeError, ValueError) as e:
129+
except (TypeError, ValueError):
130130
return obj
131131

132132
def __str__(self) -> str:

nepali/number/_number.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,46 @@ class NepaliNumber:
1313
@classmethod
1414
def convert_and_add_comma(cls, number):
1515
warnings.warn(
16-
message="NepaliNumber.convert_and_add_comma has been moved to `convert_and_add_comma. This function is depreciated and will be removed in the future release.",
16+
message="NepaliNumber.convert_and_add_comma has been moved to "
17+
"`convert_and_add_comma. This function is depreciated and will "
18+
"be removed in the future release.",
1719
category=DeprecationWarning,
1820
)
1921
return add_comma(english_to_nepali(number))
2022

2123
@staticmethod
2224
def convert(num):
2325
warnings.warn(
24-
message="NepaliNumber.convert has been moved to `english_to_nepali. This function is depreciated and will be removed in the future release.",
26+
message="NepaliNumber.convert has been moved to `english_to_nepali. "
27+
"This function is depreciated and will be removed in the future release.",
2528
category=DeprecationWarning,
2629
)
2730
return english_to_nepali(num)
2831

2932
@staticmethod
3033
def revert(num):
3134
warnings.warn(
32-
message="NepaliNumber.revert has been moved to `nepali_to_english. This function is depreciated and will be removed in the future release.",
35+
message="NepaliNumber.revert has been moved to `nepali_to_english. "
36+
"This function is depreciated and will be removed in the future release.",
3337
category=DeprecationWarning,
3438
)
3539
return nepali_to_english(num)
3640

3741
@staticmethod
3842
def add_comma(number):
3943
warnings.warn(
40-
message="NepaliNumber.add_comma has been moved to `add_comma. This function is depreciated and will be removed in the future release.",
44+
message="NepaliNumber.add_comma has been moved to `add_comma. "
45+
"This function is depreciated and will be removed in the future release.",
4146
category=DeprecationWarning,
4247
)
4348
return add_comma(number)
4449

4550
@staticmethod
4651
def add_comma_english(number):
4752
warnings.warn(
48-
message="NepaliNumber.add_comma_english has been moved to `add_comma_english. This function is depreciated and will be removed in the future release.",
53+
message="NepaliNumber.add_comma_english has been moved to "
54+
"`add_comma_english. This function is depreciated and will "
55+
"be removed in the future release.",
4956
category=DeprecationWarning,
5057
)
5158
return add_comma_english(number)

nepali/phone_number.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def is_mobile_number(number: str) -> bool:
3333
"""
3434
try:
3535
return bool(_mobile_number_re.match(number))
36-
except:
36+
except Exception:
3737
return False
3838

3939

@@ -47,7 +47,7 @@ def is_landline_number(number: str) -> bool:
4747
"""
4848
try:
4949
return bool(_landline_number_re.match(number))
50-
except:
50+
except Exception:
5151
return False
5252

5353

nepali/tests/test_number.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,23 +2961,23 @@ def test_nepalinumber_raises_exception_for_chars_english(self):
29612961
)
29622962

29632963
def test_nepalinumber_raises_exception_for_chars_nepali(self):
2964-
with self.assertRaises(ValueError) as ex:
2964+
with self.assertRaises(ValueError):
29652965
nepalinumber("आइतबार")
29662966

29672967
def test_nepalinumber_raises_exception_for_two_dots(self):
2968-
with self.assertRaises(ValueError) as ex:
2968+
with self.assertRaises(ValueError):
29692969
nepalinumber("10..5")
29702970

29712971
def test_nepalinumber_raises_exception_for_nepali_aplha(self):
2972-
with self.assertRaises(ValueError) as ex:
2972+
with self.assertRaises(ValueError):
29732973
nepalinumber("10..5")
29742974

29752975
def test_nepalinumber_raises_exception_for_special_chars(self):
2976-
with self.assertRaises(ValueError) as ex:
2976+
with self.assertRaises(ValueError):
29772977
nepalinumber("!@#$%^&*()-+")
29782978

29792979
def test_nepalinumber_raise_exception_for_number_with_spaces(self):
2980-
with self.assertRaises(ValueError) as ex:
2980+
with self.assertRaises(ValueError):
29812981
nepalinumber("10 20")
29822982

29832983
def test_nepalinumber_raises_exception_on_complex_number(self):

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
version="1.0.0",
3838
author="opensource-nepal",
3939
40-
description="nepalidatetime compatible with python's datetime feature. Converting nepali date to english, parsing nepali datetime, nepali timezone, and timedelta support in nepali datetime",
40+
description="nepalidatetime compatible with python's datetime feature. "
41+
"Converting nepali date to english, parsing nepali datetime, "
42+
"nepali timezone, and timedelta support in nepali datetime",
4143
long_description=long_description,
4244
long_description_content_type="text/markdown",
4345
keywords=[

0 commit comments

Comments
 (0)