Skip to content

Commit 72c7cce

Browse files
committed
fix to pep8
1 parent ea734f6 commit 72c7cce

File tree

545 files changed

+5884
-4609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

545 files changed

+5884
-4609
lines changed

.pre-commit-config.yaml

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
repos:
2+
- repo: https://github.com/asottile/add-trailing-comma
3+
rev: v3.1.0
4+
hooks:
5+
- id: add-trailing-comma
6+
- repo: https://github.com/psf/black.git
7+
rev: 24.4.0
8+
hooks:
9+
- id: black
10+
- repo: https://github.com/nbQA-dev/nbQA
11+
rev: 1.8.5
12+
hooks:
13+
- id: nbqa-black
14+
name: nbqa-black
15+
description: Run 'black' on a Jupyter Notebook
16+
entry: nbqa black
17+
language: python
18+
require_serial: true
19+
types_or: [jupyter, markdown]
20+
additional_dependencies: [black]
21+
- repo: https://github.com/asottile/pyupgrade
22+
rev: v3.15.2
23+
hooks:
24+
- id: pyupgrade
25+
args: [--py39-plus]
26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.13.2
28+
hooks:
29+
- id: isort
30+
- repo: https://github.com/adamchainz/blacken-docs
31+
rev: 1.16.0
32+
hooks:
33+
- id: blacken-docs
34+
additional_dependencies:
35+
- black==24.2.0
36+
- repo: https://github.com/nbQA-dev/nbQA
37+
rev: 1.8.5
38+
hooks:
39+
- id: nbqa-pyupgrade
40+
name: nbqa-pyupgrade
41+
description: Run 'pyupgrade' on a Jupyter Notebook
42+
entry: nbqa pyupgrade
43+
language: python
44+
require_serial: true
45+
types_or: [jupyter, markdown]
46+
additional_dependencies: [pyupgrade]
47+
- id: nbqa-isort
48+
name: nbqa-isort
49+
description: Run 'isort' on a Jupyter Notebook
50+
entry: nbqa isort
51+
language: python
52+
require_serial: true
53+
types_or: [jupyter, markdown]
54+
additional_dependencies: [isort]
55+
56+
- repo: https://github.com/pre-commit/pre-commit-hooks
57+
rev: v4.6.0
58+
hooks:
59+
- id: trailing-whitespace
60+
- id: end-of-file-fixer
61+
- id: check-yaml
62+
- id: debug-statements
63+
- id: name-tests-test
64+
- id: requirements-txt-fixer
65+
66+
- repo: https://github.com/codespell-project/codespell
67+
rev: v2.2.6
68+
hooks:
69+
- id: codespell
70+
additional_dependencies:
71+
- tomli
72+
73+
- repo: https://github.com/nbQA-dev/nbQA
74+
rev: 1.8.5
75+
hooks:
76+
- id: nbqa-flake8
77+
args: ["--ignore=E501,E712,W291,F632,E203"]
78+
name: nbqa-flake8
79+
description: Run 'flake8' on a Jupyter Notebook
80+
entry: nbqa flake8
81+
language: python
82+
require_serial: true
83+
types_or: [jupyter, markdown]
84+
additional_dependencies:
85+
- flake8-variables-names
86+
- pep8-naming
87+
- flake8-functions-names
88+
89+
- repo: https://github.com/PyCQA/flake8
90+
rev: 7.0.0
91+
hooks:
92+
- id: flake8
93+
args: ["--ignore=E501,E712,W291,F632,E203"]
94+
additional_dependencies:
95+
- flake8-variables-names
96+
- pep8-naming
97+
- flake8-functions-names
98+
99+
- repo: https://github.com/nbQA-dev/nbQA
100+
rev: 1.8.5
101+
hooks:
102+
- id: nbqa-mypy
103+
name: nbqa-mypy
104+
description: Run 'mypy' on a Jupyter Notebook
105+
entry: nbqa mypy
106+
language: python
107+
require_serial: true
108+
types_or: [jupyter, markdown]
109+
additional_dependencies:
110+
- mypy
111+
- pandas-stubs
112+
- git+https://github.com/numpy/numpy-stubs
113+
- mypy-extensions
114+
- types-requests
115+
- types-PyYAML
116+
- types-setuptools
117+
118+
args:
119+
- --cache-dir=/dev/null
120+
- --cache-dir=nul
121+
- --no-incremental
122+
- --explicit-package-bases
123+
- --ignore-missing-imports
124+
- --disallow-untyped-calls
125+
- --disallow-untyped-defs
126+
- --disallow-untyped-decorators
127+
- --strict
128+
- --extra-checks
129+
- --disallow-any-unimported
130+
- --disallow-any-decorated
131+
- --disallow-any-explicit
132+
- --disallow-any-generics
133+
- --disallow-subclassing-any
134+
- --local-partial-types
135+
- --pretty
136+
- --force-uppercase-builtins
137+
- --force-union-syntax
138+
- --warn-unreachable
139+
- --warn-redundant-casts
140+
- --warn-return-any
141+
142+
143+
144+
- repo: https://github.com/pre-commit/mirrors-mypy
145+
rev: v1.9.0
146+
hooks:
147+
- id: mypy
148+
args:
149+
- --cache-dir=/dev/null
150+
- --cache-dir=nul
151+
- --no-incremental
152+
- --explicit-package-bases
153+
- --ignore-missing-imports
154+
- --disallow-untyped-calls
155+
- --disallow-untyped-defs
156+
- --disallow-untyped-decorators
157+
- --strict
158+
- --extra-checks
159+
- --disallow-any-unimported
160+
- --disallow-any-decorated
161+
- --disallow-any-explicit
162+
- --disallow-any-generics
163+
- --disallow-subclassing-any
164+
- --local-partial-types
165+
- --pretty
166+
- --force-uppercase-builtins
167+
- --force-union-syntax
168+
- --warn-unreachable
169+
- --warn-redundant-casts
170+
- --warn-return-any
171+
172+
173+
174+
additional_dependencies:
175+
- mypy
176+
- pandas-stubs
177+
- git+https://github.com/numpy/numpy-stubs
178+
- mypy-extensions
179+
- types-requests
180+
- types-PyYAML
181+
- types-setuptools
182+
183+
- repo: https://github.com/nbQA-dev/nbQA
184+
rev: 1.8.5
185+
hooks:
186+
- id: nbqa-pylint
187+
name: nbqa-pylint
188+
description: Run 'pylint' on a Jupyter Notebook
189+
entry: nbqa pylint
190+
language: python
191+
require_serial: true
192+
types_or: [jupyter, markdown]
193+
additional_dependencies: [pylint]
194+
args:
195+
[
196+
"--max-line-length=79",
197+
"--const-naming-style=any",
198+
"--disable=E0401,W0104",
199+
]
200+
201+
- repo: https://github.com/pre-commit/mirrors-pylint
202+
rev: v2.3.1
203+
hooks:
204+
- id: pylint
205+
name: pylint
206+
entry: pylint
207+
language: python
208+
types: [python]
209+
args:
210+
[--max-line-length=79, "--const-naming-style=any", "--disable=E0401,W0104"]
211+
additional_dependencies: [pylint]
212+
213+
- repo: https://github.com/nbQA-dev/nbQA
214+
rev: 1.8.5
215+
hooks:
216+
- id: nbqa-pydocstyle
217+
name: nbqa-pydocstyle
218+
description: Run 'pydocstyle' on a Jupyter Notebook
219+
entry: nbqa pydocstyle
220+
language: python
221+
require_serial: true
222+
types_or: [jupyter, markdown]
223+
additional_dependencies: [pydocstyle]

1 File handle/File handle binary/Update a binary file2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def update():
99
value = pickle.load(File)
1010
found = False
1111
roll = int(input("Enter the roll number of the record"))
12-
12+
1313
for i in value:
1414
if roll == i[0]:
1515
print(f"current name {i[1]}")

1 File handle/File handle binary/question 1 (elegible for remedial, top marks).py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
Write a function remcount( ) to count the number of students who need
77
remedial class (student who scored less than 40 percent)
88
9-
9+
1010
"""
11+
1112
# also find no. of children who got top marks
1213

1314
import pickle

1 File handle/File handle text/counter.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
- Code readability
66
"""
77

8+
89
class Counter:
910

10-
def __init__(self, text:str) -> None:
11+
def __init__(self, text: str) -> None:
1112
self.text = text
1213

1314
# Define the initial count of the lower and upper case.
@@ -16,20 +17,20 @@ def __init__(self, text:str) -> None:
1617
self.count()
1718

1819
def count(self) -> None:
19-
20+
2021
for char in self.text:
2122
if char.lower():
2223
self.count_lower += 1
2324
elif char.upper():
2425
self.count_upper += 1
2526

2627
return (self.count_lower, self.count_upper)
27-
28+
2829
def get_total_lower(self) -> int:
2930
return self.count_lower
3031

3132
def get_total_upper(self) -> int:
3233
return self.count_upper
3334

3435
def get_total(self) -> int:
35-
return self.count_lower + self.count_upper
36+
return self.count_lower + self.count_upper
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
21
import os
32
import time
4-
file_name= input("Enter the file name to create:- ")
3+
4+
file_name = input("Enter the file name to create:- ")
55

66
print(file_name)
77

8+
89
def write_to_file(file_name):
910

1011
if os.path.exists(file_name):
@@ -15,24 +16,26 @@ def write_to_file(file_name):
1516

1617
while True:
1718
text = input("enter any text to add in the file:- ")
18-
F.write( f"{text}\n" )
19+
F.write(f"{text}\n")
1920
choice = input("Do you want to enter more, y/n").lower()
2021
if choice == "n":
2122
break
22-
23+
24+
2325
def longlines():
2426

25-
with open(file_name, encoding='utf-8') as F:
27+
with open(file_name, encoding="utf-8") as F:
2628
lines = F.readlines()
27-
lines_less_than_50 = list( filter(lambda line: len(line) < 50, lines ) )
29+
lines_less_than_50 = list(filter(lambda line: len(line) < 50, lines))
2830

2931
if not lines_less_than_50:
3032
print("There is no line which is less than 50")
3133
else:
3234
for i in lines_less_than_50:
3335
print(i, end="\t")
3436

37+
3538
if __name__ == "__main__":
3639
write_to_file(file_name)
3740
time.sleep(1)
38-
longlines()
41+
longlines()

1 File handle/File handle text/happy.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Take a walk in the park
88
At the end of the day you are more important than anything else.
99
Many moments of happiness are waiting
1010
You are amazing!
11-
If you truly believe.
11+
If you truly believe.

1 File handle/File handle text/input,output and error streams.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
sys.stdout.write("Enter the name of the file")
55
file = sys.stdin.readline()
66

7-
with open(file.strip(), ) as F:
7+
with open(file.strip()) as F:
88

99
while True:
1010
ch = F.readlines()
11-
for (i) in ch: # ch is the whole file,for i in ch gives lines, for j in i gives letters,for j in i.split gives words
11+
for (
12+
i
13+
) in (
14+
ch
15+
): # ch is the whole file,for i in ch gives lines, for j in i gives letters,for j in i.split gives words
1216
print(i, end="")
1317
else:
1418
sys.stderr.write("End of file reached")
1519
break
16-

1 File handle/File handle text/question 2.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,32 @@
33
using read function
44
and display those words, which are less than 4 characters. """
55

6+
print("Hey!! You can print the word which are less then 4 characters")
67

7-
print("Hey!! You can print the word which are less then 4 characters")
88

99
def display_words(file_path):
1010

1111
try:
1212
with open(file_path) as F:
1313
words = F.read().split()
14-
words_less_than_40 = list( filter(lambda word: len(word) < 4, words) )
14+
words_less_than_40 = list(filter(lambda word: len(word) < 4, words))
1515

1616
for word in words_less_than_40:
1717
print(word)
18-
19-
return "The total number of the word's count which has less than 4 characters", (len(words_less_than_40))
20-
18+
19+
return (
20+
"The total number of the word's count which has less than 4 characters",
21+
(len(words_less_than_40)),
22+
)
23+
2124
except FileNotFoundError:
2225
print("File not found")
2326

27+
2428
print("Just need to pass the path of your file..")
2529

2630
file_path = input("Please, Enter file path: ")
2731

2832
if __name__ == "__main__":
29-
30-
print(display_words(file_path))
31-
32-
33-
34-
3533

34+
print(display_words(file_path))

0 commit comments

Comments
 (0)