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

CM-41176 - Add Python 3.13 support; drop Python 3.7 support #255

Merged
merged 6 commits into from
Oct 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build_executable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]

runs-on: ${{matrix.os}}

Expand Down Expand Up @@ -50,13 +50,13 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ matrix.os }}-1 # increment to reset cache
key: poetry-${{ matrix.os }}-${{ matrix.python-version }}-1 # increment to reset cache

- name: Setup Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.5.1
version: 1.8.3

- name: Add Poetry to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Expand All @@ -65,6 +65,7 @@ jobs:
run: poetry install

- name: Run executable test
if: matrix.python-version != '3.13' # we will migrate pyinstaller to 3.13 later
run: |
poetry run pyinstaller pyinstaller.spec
./dist/cycode-cli version
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

## How to contribute to Cycode CLI

The minimum version of Python that we support is 3.7.
The minimum version of Python that we support is 3.8.
We recommend using this version for local development.
But it’s fine to use a higher version without using new features from these versions.
We prefer 3.8 because it comes with the support of Apple Silicon, and it is as low as possible.

The project is under Poetry project management.
To deal with it, you should install it on your system:
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ This guide will guide you through both installation and usage.

# Prerequisites

> [!WARNING]
> Python 3.7 end-of-life was on 2023-06-27.
> It is recommended to use Python 3.8 or later.
> We will drop support for Python 3.7 soon.

- The Cycode CLI application requires Python version 3.7 or later.
- The Cycode CLI application requires Python version 3.8 or later.
- Use the [`cycode auth` command](#using-the-auth-command) to authenticate to Cycode with the CLI
- Alternatively, you can obtain a Cycode Client ID and Client Secret Key by following the steps detailed in the [Service Account Token](https://docs.cycode.com/reference/creating-a-service-account-access-token) and [Personal Access Token](https://docs.cycode.com/reference/creating-a-personal-access-token-1) pages, which contain details on obtaining these values.

Expand Down
4 changes: 1 addition & 3 deletions cycode/cli/commands/scan/code_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ def scan_commit_range(

progress_bar.set_section_length(ScanProgressBarSection.PREPARE_LOCAL_FILES, total_commits_count)

scanned_commits_count = 0
for commit in repo.iter_commits(rev=commit_range):
for scanned_commits_count, commit in enumerate(repo.iter_commits(rev=commit_range)):
if _does_reach_to_max_commits_to_scan_limit(commit_ids_to_scan, max_commits_count):
logger.debug('Reached to max commits to scan count. Going to scan only %s last commits', max_commits_count)
progress_bar.update(ScanProgressBarSection.PREPARE_LOCAL_FILES, total_commits_count - scanned_commits_count)
Expand Down Expand Up @@ -284,7 +283,6 @@ def scan_commit_range(
)

documents_to_scan.extend(exclude_irrelevant_documents_to_scan(scan_type, commit_documents_to_scan))
scanned_commits_count += 1

logger.debug('List of commit ids to scan, %s', {'commit_ids': commit_ids_to_scan})
logger.debug('Starting to scan commit range (it may take a few minutes)')
Expand Down
12 changes: 4 additions & 8 deletions cycode/cli/exceptions/custom_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ class CycodeError(Exception):
"""Base class for all custom exceptions"""


class RequestError(CycodeError):
...
class RequestError(CycodeError): ...


class RequestTimeout(RequestError):
...
class RequestTimeout(RequestError): ...


class RequestConnectionError(RequestError):
...
class RequestConnectionError(RequestError): ...


class RequestSslError(RequestConnectionError):
...
class RequestSslError(RequestConnectionError): ...


class RequestHttpError(RequestError):
Expand Down
5 changes: 1 addition & 4 deletions cycode/cli/files_collector/excluder.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ def _is_relevant_file_to_scan(scan_type: str, filename: str) -> bool:
)
return False

if scan_type == consts.SCA_SCAN_TYPE and not _is_file_relevant_for_sca_scan(filename):
return False

return True
return not (scan_type == consts.SCA_SCAN_TYPE and not _is_file_relevant_for_sca_scan(filename))


def _is_file_relevant_for_sca_scan(filename: str) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions cycode/cli/user_settings/base_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

class BaseFileManager(ABC):
@abstractmethod
def get_filename(self) -> str:
...
def get_filename(self) -> str: ...

def read_file(self) -> Dict[Hashable, Any]:
return read_file(self.get_filename())
Expand Down
12 changes: 4 additions & 8 deletions cycode/cli/utils/git_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ class GitProxyError(Exception):

class _AbstractGitProxy(ABC):
@abstractmethod
def get_repo(self, path: Optional['PathLike'] = None, *args, **kwargs) -> 'Repo':
...
def get_repo(self, path: Optional['PathLike'] = None, *args, **kwargs) -> 'Repo': ...

@abstractmethod
def get_null_tree(self) -> object:
...
def get_null_tree(self) -> object: ...

@abstractmethod
def get_invalid_git_repository_error(self) -> Type[BaseException]:
...
def get_invalid_git_repository_error(self) -> Type[BaseException]: ...

@abstractmethod
def get_git_command_error(self) -> Type[BaseException]:
...
def get_git_command_error(self) -> Type[BaseException]: ...


class _DummyGitProxy(_AbstractGitProxy):
Expand Down
21 changes: 7 additions & 14 deletions cycode/cli/utils/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,25 @@ def __init__(self, *args, **kwargs) -> None:
pass

@abstractmethod
def __enter__(self) -> 'BaseProgressBar':
...
def __enter__(self) -> 'BaseProgressBar': ...

@abstractmethod
def __exit__(self, *args, **kwargs) -> None:
...
def __exit__(self, *args, **kwargs) -> None: ...

@abstractmethod
def start(self) -> None:
...
def start(self) -> None: ...

@abstractmethod
def stop(self) -> None:
...
def stop(self) -> None: ...

@abstractmethod
def set_section_length(self, section: 'ProgressBarSection', length: int = 0) -> None:
...
def set_section_length(self, section: 'ProgressBarSection', length: int = 0) -> None: ...

@abstractmethod
def update(self, section: 'ProgressBarSection') -> None:
...
def update(self, section: 'ProgressBarSection') -> None: ...

@abstractmethod
def update_label(self, label: Optional[str] = None) -> None:
...
def update_label(self, label: Optional[str] = None) -> None: ...


class DummyProgressBar(BaseProgressBar):
Expand Down
4 changes: 2 additions & 2 deletions cycode/cli/utils/shell_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def shell(
logger.debug('Executing shell command: %s', command)

try:
result = subprocess.run(
result = subprocess.run( # noqa: S603
command,
timeout=timeout,
shell=execute_in_shell, # noqa: S603
shell=execute_in_shell,
check=True,
capture_output=True,
)
Expand Down
2 changes: 1 addition & 1 deletion cycode/cli/utils/task_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __exit__(

# catch the exception of interrupt_main before exiting
# the with statement and throw timeout error instead
if exc_type == KeyboardInterrupt:
if exc_type is KeyboardInterrupt:
raise TimeoutError(f'Task timed out after {self.timeout} seconds')

def timeout_function(self) -> None:
Expand Down
6 changes: 2 additions & 4 deletions cycode/cyclient/scan_config_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

class ScanConfigBase(ABC):
@abstractmethod
def get_service_name(self, scan_type: str, should_use_scan_service: bool = False) -> str:
...
def get_service_name(self, scan_type: str, should_use_scan_service: bool = False) -> str: ...

@staticmethod
def get_async_scan_type(scan_type: str) -> str:
Expand All @@ -25,8 +24,7 @@ def get_async_entity_type(scan_type: str) -> str:
return 'repository'

@abstractmethod
def get_detections_prefix(self) -> str:
...
def get_detections_prefix(self) -> str: ...


class DevScanConfig(ScanConfigBase):
Expand Down
Loading
Loading