Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#433 Feature/SG 143 black formatter

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-143-black-formatter
6 changed files with 75 additions and 18 deletions
  1. 8
    5
      .circleci/config.yml
  2. 19
    0
      .pre-commit-config.yaml
  3. 28
    0
      pyproject.toml
  4. 3
    1
      requirements.dev.txt
  5. 6
    1
      scripts/flake8-config
  6. 11
    11
      setup.py
@@ -50,13 +50,17 @@ jobs:
                   equal: [ master, << pipeline.git.branch >> ]
           steps:
             - run:
-                name: install Flake8 python linter
+                name: install Black Flake8 python linter
                 command: |
-                  pip install --user flake8
+                  pip install --user -r requirements.dev.txt
             - run:
                 name: Lint all python files changed since develop branch
                 command: |
                   flake8 --statistics --config scripts/flake8-config setup.py $(git diff --diff-filter ACM origin/master --name-only | grep 'py$' | grep -v 'experimental/' | grep -v 'experimental_models/')
+            - run:
+                name: Run Black on changed files against master branch
+                command: |
+                  black --check setup.py $(git diff --diff-filter ACM origin/master --name-only | grep 'py$' | grep -v 'experimental/' | grep -v 'experimental_models/')
       - run:
           name: add requirements.txt and requirements.pro.txt to source code
           command: |
@@ -67,7 +71,7 @@ jobs:
           command: |
             python3 -m venv venv
             . venv/bin/activate
-            python3 -m pip install pip==22.0.4 
+            python3 -m pip install pip==22.0.4
             cat requirements.txt | cut -f1 -d"#" | xargs -n 1 -L 1 pip install --progress-bar off
       - run:
           name: edit package version
@@ -122,7 +126,7 @@ jobs:
       - deci-common/git_config_automation_user
       - run:
           name: "commit version file"
-          command: | 
+          command: |
             git commit version.txt -m "Deci Services - Changed version to $NEW_VERSION"
       - deci-common/git_commit_and_tag:
           version: $NEW_VERSION
@@ -227,4 +231,3 @@ workflows:
           requires:
             - "build3.7"
           <<: *release_candidate_filter
-
Discard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  1. repos:
  2. - repo: https://github.com/pre-commit/pre-commit-hooks
  3. rev: v2.3.0
  4. hooks:
  5. - id: check-yaml
  6. - id: check-toml
  7. - id: end-of-file-fixer
  8. - repo: https://github.com/psf/black
  9. rev: 22.10.0
  10. hooks:
  11. - id: black
  12. args: [ --config=pyproject.toml ]
  13. - repo: https://github.com/pycqa/flake8
  14. rev: 5.0.4
  15. hooks:
  16. - id: flake8
  17. args: [ --config=scripts/flake8-config ]
Discard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  1. ## Super-Gradients configuration for black/mypy/isort etc tools.
  2. [tool.isort]
  3. profile = "black"
  4. multi_line_output = 3
  5. include_trailing_comma = true
  6. force_grid_wrap = 0
  7. use_parentheses = true
  8. ensure_newline_before_comments = true
  9. line_length = 160
  10. ## Configuration for Black.
  11. [tool.black]
  12. line-length = 160
  13. target-version = ['py36', 'py37', 'py38', 'py39' ]
  14. include = '\.pyi?$'
  15. exclude = '''
  16. /(
  17. \.eggs
  18. | \.git
  19. | \.circleci
  20. | \.venv
  21. | _build
  22. | buck-out
  23. | build
  24. | dist
  25. )/
  26. '''
Discard
@@ -1 +1,3 @@
-flake8
+flake8==5.0.4
+black==22.10.0
+pre-commit==2.20.0
Discard
@@ -1,5 +1,10 @@
 [flake8]
-ignore = E731, C901, W504 # lambda functions, function too complex, line break after binary operator
+ignore = E731, C901, W503, W504 # lambda functions, function too complex, line break after binary operator
+
+# In order to make flake8 compatible with black formatting
+# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html
+extend-ignore = E203
+
 max-line-length = 160
 max-complexity = 10
 exclude =
Discard
@@ -7,9 +7,9 @@
 from setuptools import setup
 from setuptools import find_packages
 
-README_LOCATION = 'README.md'
-REQ_LOCATION = 'requirements.txt'
-REQ_PRO_LOCATION = 'requirements.pro.txt'
+README_LOCATION = "README.md"
+REQ_LOCATION = "requirements.txt"
+REQ_PRO_LOCATION = "requirements.pro.txt"
 VERSION_FILE = "version.txt"
 
 
@@ -35,7 +35,7 @@ def get_version():
 
 
 setup(
-    name='super-gradients',
+    name="super-gradients",
     version=get_version(),
     description="SuperGradients",
     author="Deci AI",
@@ -43,15 +43,15 @@ setup(
     url="https://deci-ai.github.io/super-gradients/welcome.html",
     keywords=["Deci", "AI", "Training", "Deep Learning", "Computer Vision", "PyTorch", "SOTA", "Recipes", "Pre Trained", "Models"],
     install_requires=get_requirements(),
-    packages=find_packages(where='./src'),
-    package_dir={'': 'src'},
+    packages=find_packages(where="./src"),
+    package_dir={"": "src"},
     package_data={
-        'super_gradients.recipes': ['*.yaml', '**/*.yaml'],
-        'super_gradients.common': ['auto_logging/auto_logging_conf.json'],
-        'super_gradients.examples': ['*.ipynb', '**/*.ipynb'],
-        'super_gradients': ['requirements.txt', 'requirements.pro.txt'],
+        "super_gradients.recipes": ["*.yaml", "**/*.yaml"],
+        "super_gradients.common": ["auto_logging/auto_logging_conf.json"],
+        "super_gradients.examples": ["*.ipynb", "**/*.ipynb"],
+        "super_gradients": ["requirements.txt", "requirements.pro.txt"],
     },
     long_description=readme(),
     long_description_content_type="text/markdown",
-    extras_require={"pro": get_pro_requirements()}
+    extras_require={"pro": get_pro_requirements()},
 )
Discard