Skip to content

fix code use black #2610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix code use black
  • Loading branch information
ruslansenatorov committed Apr 10, 2025
commit 8a2902d53ec0c08f614eae7f6c6e2e8a68ef85e2
253 changes: 253 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
repos:
- repo: https://github.com/mwouts/jupytext
rev: "v1.16.4b"
hooks:
- id: jupytext
entry: jupytext
language: python
types: [jupyter]
args:
- --from=ipynb
- --to=py:light
- --set-formats=ipynb,py:light
- --quiet
- --sync
- --warn-only
exclude: '.*\.md$'
- repo: https://github.com/PyCQA/docformatter
rev: "eb1df347edd128b30cd3368dddc3aa65edcfac38"
hooks:
- id: docformatter
args: [--in-place, --wrap-descriptions=79, --style=google]
- repo: https://github.com/psf/black.git
rev: "24.10.0"
hooks:
- id: black

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-black
name: nbqa-black
description: Run 'black' on a Jupyter Notebook
entry: nbqa black
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies: [black]
- repo: https://github.com/asottile/pyupgrade
rev: "v3.19.0"
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort
entry: isort
args:
- --profile=black
- --float-to-top

- repo: https://github.com/nbQA-dev/nbQA
rev: "1.9.0"
hooks:
- id: nbqa
entry: nbqa blacken-docs
name: nbqa-blacken-docs
alias: nbqa-blacken-docs
additional_dependencies: [blacken-docs]
args:
- --nbqa-md
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-pyupgrade
name: nbqa-pyupgrade
description: Run 'pyupgrade' on a Jupyter Notebook
entry: nbqa pyupgrade
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies: [pyupgrade]
- id: nbqa-isort
name: nbqa-isort
description: Run 'isort' on a Jupyter Notebook
entry: nbqa isort
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies: [isort]
args:
- --profile=black
- --float-to-top

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
args:
- --ignore-regex=^\s*"image\/(jpeg|png|gif|bmp|tiff)":\s.*
- --ignore-regex=[A-Za-z0-9+/]{100,}
- --skip=*.js,*.html,*.css,*.svg",*.json,*.png,*.jpg,*.yml,*.yaml
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-flake8
args:
- --ignore=E501,E712,W291,F632,E203,F821,F403,W391,F401
- --exclude=.*,__init__.py
name: nbqa-flake8
description: Run 'flake8' on a Jupyter Notebook
entry: nbqa flake8
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies:
- flake8-variables-names
- pep8-naming
- flake8-functions-names

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
args:
- --ignore=E501,E712,W291,F632,E203,F821,F403,W391,F401
- --exclude=.*,__init__.py
additional_dependencies:
- flake8-variables-names
- pep8-naming
- flake8-functions-names

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-mypy
name: nbqa-mypy
description: Run 'mypy' on a Jupyter Notebook
entry: nbqa mypy
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies:
- mypy
- pandas-stubs
- git+https://github.com/numpy/numpy-stubs
- mypy-extensions
- types-requests
- types-PyYAML
- types-setuptools

args:
# - --cache-dir=/dev/null
# - --cache-dir=nul
# - --no-incremental
- --non-interactive
- --install-types
- --explicit-package-bases
- --ignore-missing-imports
- --disallow-untyped-calls
- --disallow-untyped-defs
- --disallow-untyped-decorators
- --strict
- --extra-checks
- --disallow-any-decorated
- --disallow-any-generics
- --local-partial-types
- --pretty
- --force-uppercase-builtins
- --force-union-syntax
- --warn-unreachable
- --warn-redundant-casts
- --warn-return-any
- --disallow-any-explicit



- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args:
# - --cache-dir=/dev/null
# - --cache-dir=nul
# - --no-incremental
- --non-interactive
- --install-types
- --explicit-package-bases
- --ignore-missing-imports
- --disallow-untyped-calls
- --disallow-untyped-defs
- --disallow-untyped-decorators
- --strict
- --extra-checks
- --disallow-any-decorated
- --disallow-any-generics
- --local-partial-types
- --pretty
- --force-uppercase-builtins
- --force-union-syntax
- --warn-unreachable
- --warn-redundant-casts
- --warn-return-any
- --disallow-any-explicit


additional_dependencies:
- mypy
- pandas-stubs
- git+https://github.com/numpy/numpy-stubs
- mypy-extensions
- types-requests
- types-PyYAML
- types-setuptools

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-pylint
name: nbqa-pylint
description: Run 'pylint' on a Jupyter Notebook
entry: nbqa pylint
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies: [pylint]
args:
- --ignore=no_check*,__init__.py
- --max-line-length=79
- --const-naming-style=any
- --disable=E0401,W0104,R0903,R1721,E1101,E0611,F0002,C0305,C0303,E2515


- repo: https://github.com/pylint-dev/pylint
rev: "v3.3.1"
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
args:
[
"--ignore=no_check*,__init__.py",
"--max-line-length=79",
"--const-naming-style=any",
"--disable=E0401,W0104,R0903,R1721,E1101,E0611,F0002,C0305,line-too-long,C0303,E2515"
]
additional_dependencies: [pylint]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
hooks:
- id: nbqa-pydocstyle
name: nbqa-pydocstyle
description: Run 'pydocstyle' on a Jupyter Notebook
entry: nbqa pydocstyle
language: python
require_serial: true
types_or: [jupyter, markdown]
additional_dependencies: [pydocstyle]
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Amit is a monitor of class XII-A and he stored the record of all
the students of his class in a file named “class.dat”.
Structure of record is [roll number, name, percentage]. His computer
teacher has assigned the following duty to Amit

Write a function remcount( ) to count the number of students who need
remedial class (student who scored less than 40 percent)


"""
"""Amit is a monitor of class XII-A and he stored the record of all the
students of his class in a file named “class.dat”. Structure of record is [roll
number, name, percentage]. His computer teacher has assigned the following duty
to Amit.

Write a function remcount( ) to count the number of students who need remedial
class (student who scored less than 40 percent)
"""

# also find no. of children who got top marks

Expand Down
7 changes: 3 additions & 4 deletions 1 File handle/File handle text/question 2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" Write a method/function DISPLAYWORDS() in python to read lines
from a text file STORY.TXT,
using read function
and display those words, which are less than 4 characters. """
"""Write a method/function DISPLAYWORDS() in python to read lines from a text
file STORY.TXT, using read function and display those words, which are less
than 4 characters."""

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

Expand Down
4 changes: 2 additions & 2 deletions 1 File handle/File handle text/question 5.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Write a function in python to count the number of lowercase
alphabets present in a text file “happy.txt"""
"""Write a function in python to count the number of lowercase alphabets
present in a text file “happy.txt."""

import os
import time
Expand Down
4 changes: 2 additions & 2 deletions 1 File handle/File handle text/question 6.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Write a function in python to count the number of lowercase
alphabets present in a text file “happy.txt"""
"""Write a function in python to count the number of lowercase alphabets
present in a text file “happy.txt."""

from counter import Counter

Expand Down
6 changes: 3 additions & 3 deletions 1 File handle/File handle text/question3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Write a user-defined function named count() that will read
the contents of text file named “happy.txt” and count
the number of lines which starts with either “I‟ or “M‟."""
"""Write a user-defined function named count() that will read the contents of
text file named “happy.txt” and count the number of lines which starts with
either “I‟ or “M‟."""

import os
import time
Expand Down
1 change: 1 addition & 0 deletions A solution to project euler problem 3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# def solution(n: int) -> int:
def solution(n: int = 600851475143) -> int:
"""Returns the largest prime factor of a given number n.

>>> solution(13195)
29
>>> solution(10)
Expand Down
5 changes: 3 additions & 2 deletions AI Game/Tic-Tac-Toe-AI/tictactoe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import random
import tkinter as tk # provides a library of basic elements of GUI widgets
from tkinter import \
messagebox # provides a different set of dialogues that are used to display message boxes
from tkinter import ( # provides a different set of dialogues that are used to display message boxes
messagebox,
)


def check_winner(board, player):
Expand Down
6 changes: 4 additions & 2 deletions Armstrong_number.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
In number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number),
"""In number theory, a narcissistic number (also known as a pluperfect digital
invariant (PPDI), an Armstrong number (after Michael F.

Armstrong) or a plus perfect number),
in a given number base b, is a number that is the total of its own digits each raised to the power of the number of digits.
Source: https://en.wikipedia.org/wiki/Narcissistic_number
NOTE:
Expand Down
15 changes: 5 additions & 10 deletions Assembler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ def parser():


def setZeroFlag(token, tmpToken):
"""return bool for zero flag based on the regToken"""
"""Return bool for zero flag based on the regToken."""
global eax, ebx, ecx, edx

# Register in string
Expand Down Expand Up @@ -1507,9 +1507,8 @@ def setZeroFlag(token, tmpToken):


def registerLabels():
"""
This function search for labels / subprogram-labels and registers this in the 'jumps' list.
"""
"""This function search for labels / subprogram-labels and registers this
in the 'jumps' list."""
for i in range(len(tokens)):
if tokens[i].t == "label":
jumps[tokens[i].token] = i
Expand All @@ -1518,9 +1517,7 @@ def registerLabels():


def resetInterpreter():
"""
resets the interpreter mind.
"""
"""Resets the interpreter mind."""
global eax, ebx, ecx, edx, zeroFlag, stack
global variables, jumps, lines, tokens, returnStack
eax = 0
Expand All @@ -1544,9 +1541,7 @@ def resetInterpreter():

# main program
def main():
"""
reads textfiles from the command-line and interprets them.
"""
"""Reads textfiles from the command-line and interprets them."""

# [1:] because the first argument is the program itself.
for arg in sys.argv[1:]:
Expand Down
Loading