Skip to content
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

isort #324

Merged
merged 12 commits into from
Apr 5, 2020
Merged

isort #324

Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ repos:
rev: v1.5
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
2 changes: 1 addition & 1 deletion CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ git clone https://github.com/demisto/demisto-sdk.git
4. Install dev-requirements -

```shell
pip3 install <repo>/requirements-dev.txt
pip3 install -r <repo>/requirements-dev.txt
```

---
Expand Down
48 changes: 28 additions & 20 deletions demisto_sdk/__main__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
# Site packages
import os
from pkg_resources import get_distribution
import sys

from pkg_resources import get_distribution

# Third party packages
import click

# Import demisto-sdk commands
from demisto_sdk.commands.run_cmd.runner import Runner
from demisto_sdk.commands.common.configuration import Configuration
# Common tools
from demisto_sdk.commands.common.tools import (find_type,
get_last_remote_release_version,
print_error, print_warning)
from demisto_sdk.commands.create_artifacts.content_creator import \
ContentCreator
from demisto_sdk.commands.create_id_set.create_id_set import IDSetCreator
from demisto_sdk.commands.find_dependencies.find_dependencies import \
PackDependencies
from demisto_sdk.commands.format.format_module import format_manager
from demisto_sdk.commands.unify.unifier import Unifier
from demisto_sdk.commands.upload.uploader import Uploader
from demisto_sdk.commands.generate_docs.generate_integration_doc import \
generate_integration_doc
from demisto_sdk.commands.generate_docs.generate_playbook_doc import \
generate_playbook_doc
from demisto_sdk.commands.generate_docs.generate_script_doc import \
generate_script_doc
from demisto_sdk.commands.generate_test_playbook.test_playbook_generator import \
PlaybookTestsGenerator
from demisto_sdk.commands.init.initiator import Initiator
from demisto_sdk.commands.split_yml.extractor import Extractor
from demisto_sdk.commands.common.configuration import Configuration
from demisto_sdk.commands.json_to_outputs.json_to_outputs import \
json_to_outputs
from demisto_sdk.commands.lint.lint_manager import LintManager
from demisto_sdk.commands.secrets.secrets import SecretsValidator
# Import demisto-sdk commands
from demisto_sdk.commands.run_cmd.runner import Runner
from demisto_sdk.commands.run_playbook.playbook_runner import PlaybookRunner
from demisto_sdk.commands.secrets.secrets import SecretsValidator
from demisto_sdk.commands.split_yml.extractor import Extractor
from demisto_sdk.commands.unify.unifier import Unifier
from demisto_sdk.commands.upload.uploader import Uploader
from demisto_sdk.commands.validate.file_validator import FilesValidator
from demisto_sdk.commands.create_artifacts.content_creator import ContentCreator
from demisto_sdk.commands.json_to_outputs.json_to_outputs import json_to_outputs
from demisto_sdk.commands.generate_test_playbook.test_playbook_generator import PlaybookTestsGenerator
from demisto_sdk.commands.generate_docs.generate_integration_doc import generate_integration_doc
from demisto_sdk.commands.generate_docs.generate_script_doc import generate_script_doc
from demisto_sdk.commands.generate_docs.generate_playbook_doc import generate_playbook_doc
from demisto_sdk.commands.create_id_set.create_id_set import IDSetCreator
from demisto_sdk.commands.find_dependencies.find_dependencies import PackDependencies

# Common tools
from demisto_sdk.commands.common.tools import print_error, print_warning, get_last_remote_release_version, find_type


class DemistoSDK:
Expand Down
2 changes: 1 addition & 1 deletion demisto_sdk/commands/common/configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import logging
import os


class Configuration:
Expand Down
12 changes: 7 additions & 5 deletions demisto_sdk/commands/common/hook_validations/base_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import re
from abc import abstractmethod

from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.hook_validations.structure import StructureValidator
from demisto_sdk.commands.common.tools import print_error, get_release_notes_file_path, \
get_latest_release_notes_text, run_command
from demisto_sdk.commands.common.constants import ID_IN_COMMONFIELDS, ID_IN_ROOT
from demisto_sdk.commands.common.constants import (ID_IN_COMMONFIELDS,
ID_IN_ROOT, Errors)
from demisto_sdk.commands.common.hook_validations.structure import \
StructureValidator
from demisto_sdk.commands.common.tools import (get_latest_release_notes_text,
get_release_notes_file_path,
print_error, run_command)


class BaseValidator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator


class ClassifierValidator(BaseValidator):
Expand Down
3 changes: 2 additions & 1 deletion demisto_sdk/commands/common/hook_validations/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error


Expand Down
7 changes: 5 additions & 2 deletions demisto_sdk/commands/common/hook_validations/description.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import glob

from demisto_sdk.commands.common.tools import re, print_error, print_warning, os, get_yaml
from demisto_sdk.commands.common.constants import INTEGRATION_REGEX, BETA_INTEGRATION_REGEX, BETA_INTEGRATION_DISCLAIMER
from demisto_sdk.commands.common.constants import (BETA_INTEGRATION_DISCLAIMER,
BETA_INTEGRATION_REGEX,
INTEGRATION_REGEX)
from demisto_sdk.commands.common.tools import (get_yaml, os, print_error,
print_warning, re)


class DescriptionValidator:
Expand Down
12 changes: 7 additions & 5 deletions demisto_sdk/commands/common/hook_validations/docker.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.tools import get_yaml, print_error, print_warning
import re
from datetime import datetime, timedelta
from distutils.version import LooseVersion

from pkg_resources import parse_version
from datetime import datetime, timedelta
import re
import requests

import requests
from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.tools import (get_yaml, print_error,
print_warning)

# disable insecure warnings
requests.packages.urllib3.disable_warnings()
Expand Down
23 changes: 17 additions & 6 deletions demisto_sdk/commands/common/hook_validations/id.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import json
import os
import re
import json
from distutils.version import LooseVersion
from collections import OrderedDict
from distutils.version import LooseVersion

from demisto_sdk.commands.common.configuration import Configuration
from demisto_sdk.commands.common.tools import get_script_or_integration_id, collect_ids, print_error
from demisto_sdk.commands.common.constants import INTEGRATION_REGEX, TEST_PLAYBOOK_REGEX, SCRIPT_JS_REGEX, \
SCRIPT_REGEX, TEST_SCRIPT_REGEX, INTEGRATION_YML_REGEX, PLAYBOOK_REGEX, SCRIPT_YML_REGEX, SCRIPT_PY_REGEX
from demisto_sdk.commands.common.update_id_set import get_script_data, get_playbook_data, get_integration_data
from demisto_sdk.commands.common.constants import (INTEGRATION_REGEX,
INTEGRATION_YML_REGEX,
PLAYBOOK_REGEX,
SCRIPT_JS_REGEX,
SCRIPT_PY_REGEX,
SCRIPT_REGEX,
SCRIPT_YML_REGEX,
TEST_PLAYBOOK_REGEX,
TEST_SCRIPT_REGEX)
from demisto_sdk.commands.common.tools import (collect_ids,
get_script_or_integration_id,
print_error)
from demisto_sdk.commands.common.update_id_set import (get_integration_data,
get_playbook_data,
get_script_data)
from demisto_sdk.commands.unify.unifier import Unifier


Expand Down
13 changes: 9 additions & 4 deletions demisto_sdk/commands/common/hook_validations/image.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import glob
import base64
import glob

from demisto_sdk.commands.common.tools import re, print_error, os, get_yaml, checked_type
from demisto_sdk.commands.common.constants import IMAGE_REGEX, INTEGRATION_REGEX, DEFAULT_IMAGE_BASE64, \
DEFAULT_DBOT_IMAGE_BASE64, INTEGRATION_REGXES, YML_INTEGRATION_REGEXES
from demisto_sdk.commands.common.constants import (DEFAULT_DBOT_IMAGE_BASE64,
DEFAULT_IMAGE_BASE64,
IMAGE_REGEX,
INTEGRATION_REGEX,
INTEGRATION_REGXES,
YML_INTEGRATION_REGEXES)
from demisto_sdk.commands.common.tools import (checked_type, get_yaml, os,
print_error, re)


class ImageValidator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""
This module is designed to validate the correctness of incident field entities in content.
"""
import re
from distutils.version import LooseVersion
from enum import Enum, IntEnum

from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error
from enum import Enum, IntEnum
import re


class TypeFields(Enum):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from distutils.version import LooseVersion

from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error


Expand Down
20 changes: 14 additions & 6 deletions demisto_sdk/commands/common/hook_validations/integration.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from demisto_sdk.commands.common.constants import Errors, INTEGRATION_CATEGORIES, PYTHON_SUBTYPES, BANG_COMMAND_NAMES, \
DBOT_SCORES_DICT, IOC_OUTPUTS_DICT, FEED_REQUIRED_PARAMS, FETCH_REQUIRED_PARAMS
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.tools import print_error, print_warning, get_dockerimage45, server_version_compare
from demisto_sdk.commands.common.constants import (BANG_COMMAND_NAMES,
DBOT_SCORES_DICT,
FEED_REQUIRED_PARAMS,
FETCH_REQUIRED_PARAMS,
INTEGRATION_CATEGORIES,
IOC_OUTPUTS_DICT,
PYTHON_SUBTYPES, Errors)
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.hook_validations.docker import \
DockerImageValidator
from demisto_sdk.commands.common.hook_validations.utils import is_v2_file

from demisto_sdk.commands.common.hook_validations.docker import DockerImageValidator
from demisto_sdk.commands.common.tools import (get_dockerimage45, print_error,
print_warning,
server_version_compare)


class IntegrationValidator(BaseValidator):
Expand Down
3 changes: 2 additions & 1 deletion demisto_sdk/commands/common/hook_validations/layout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
"""
This module is designed to validate the existence and structure of content pack essential files in content.
"""
import os
import io
import re
import json
import os
import re

from demisto_sdk.commands.common.constants import (API_MODULES_PACK,
PACK_METADATA_CATEGORIES,
PACK_METADATA_DEPENDENCIES,
PACK_METADATA_FIELDS,
PACK_METADATA_KEYWORDS,
PACK_METADATA_PRICE,
PACK_METADATA_TAGS,
PACK_METADATA_USE_CASES,
PACKS_PACK_IGNORE_FILE_NAME,
PACKS_PACK_META_FILE_NAME,
PACKS_README_FILE_NAME,
PACKS_WHITELIST_FILE_NAME)
from demisto_sdk.commands.common.tools import pack_name_to_path
from demisto_sdk.commands.common.constants import (PACKS_WHITELIST_FILE_NAME, PACKS_PACK_IGNORE_FILE_NAME,
PACKS_PACK_META_FILE_NAME, PACKS_README_FILE_NAME,
PACK_METADATA_FIELDS, PACK_METADATA_DEPENDENCIES,
PACK_METADATA_PRICE, PACK_METADATA_KEYWORDS, PACK_METADATA_TAGS,
PACK_METADATA_CATEGORIES, PACK_METADATA_USE_CASES, API_MODULES_PACK)


class PackUniqueFilesValidator:
Expand Down
4 changes: 2 additions & 2 deletions demisto_sdk/commands/common/hook_validations/playbook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Dict

from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error

from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator


class PlaybookValidator(BaseValidator):
"""PlaybookValidator is designed to validate the correctness of the file structure we enter to content repo."""
Expand Down
6 changes: 4 additions & 2 deletions demisto_sdk/commands/common/hook_validations/readme.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from pathlib import Path
import os
from demisto_sdk.commands.common.tools import print_error, print_warning, run_command_os, get_content_path
from pathlib import Path

from demisto_sdk.commands.common.tools import (get_content_path, print_error,
print_warning, run_command_os)

NO_HTML = '<!-- NOT_HTML_DOC -->'
YES_HTML = '<!-- HTML_DOC -->'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os
import re

from demisto_sdk.commands.common.tools import run_command
from demisto_sdk.commands.common.tools import print_error, get_latest_release_notes_text, \
get_release_notes_file_path
from demisto_sdk.commands.common.tools import (get_latest_release_notes_text,
get_release_notes_file_path,
print_error, run_command)


class ReleaseNotesValidator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from distutils.version import LooseVersion

from demisto_sdk.commands.common.constants import Errors
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.tools import print_error


Expand Down
9 changes: 6 additions & 3 deletions demisto_sdk/commands/common/hook_validations/script.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from demisto_sdk.commands.common.constants import PYTHON_SUBTYPES, Errors
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.tools import print_error, server_version_compare, get_dockerimage45
from demisto_sdk.commands.common.hook_validations.docker import DockerImageValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator
from demisto_sdk.commands.common.hook_validations.docker import \
DockerImageValidator
from demisto_sdk.commands.common.hook_validations.utils import is_v2_file
from demisto_sdk.commands.common.tools import (get_dockerimage45, print_error,
server_version_compare)


class ScriptValidator(BaseValidator):
Expand Down
18 changes: 11 additions & 7 deletions demisto_sdk/commands/common/hook_validations/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

Module contains validation of schemas, ids and paths.
"""
from typing import Optional
import json
import logging
import re
import os
import json
import re
from typing import Optional

import yaml
from demisto_sdk.commands.common.configuration import Configuration
from demisto_sdk.commands.common.tools import get_remote_file, get_matching_regex, print_error
from demisto_sdk.commands.common.constants import Errors, ACCEPTED_FILE_EXTENSIONS, FILE_TYPES_PATHS_TO_VALIDATE, \
SCHEMA_TO_REGEX
from demisto_sdk.commands.format.format_constants import OLD_FILE_DEFAULT_1_FROMVERSION
from demisto_sdk.commands.common.constants import (
ACCEPTED_FILE_EXTENSIONS, FILE_TYPES_PATHS_TO_VALIDATE, SCHEMA_TO_REGEX,
Errors)
from demisto_sdk.commands.common.tools import (get_matching_regex,
get_remote_file, print_error)
from demisto_sdk.commands.format.format_constants import \
OLD_FILE_DEFAULT_1_FROMVERSION
from pykwalify.core import Core


Expand Down
3 changes: 2 additions & 1 deletion demisto_sdk/commands/common/hook_validations/widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from demisto_sdk.commands.common.hook_validations.base_validator import BaseValidator
from demisto_sdk.commands.common.hook_validations.base_validator import \
BaseValidator


class WidgetValidator(BaseValidator):
Expand Down
Loading