Skip to content

Commit

Permalink
refactor: styles in python files, Dockerfile, config in pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
tomassebestik committed Feb 7, 2024
1 parent 36ac8e0 commit 8f1ae0f
Show file tree
Hide file tree
Showing 12 changed files with 521 additions and 307 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/lint.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test_jira_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Test JIRA sync
uses: ./sync_issues_to_jira
uses: .
with:
entrypoint: ./sync_issues_to_jira/test_sync_to_jira.py
entrypoint: ./test_sync_to_jira.py
106 changes: 106 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# cache
.mypy_cache/
.ruff_cache/
__pycache__/*
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Run `pre-commit autoupdate` to update to the latest pre-commit hooks version.
# When changing the version of tools that are also installed as development dependencies (e.g., black, mypy, ruff),
# please ensure the same versions are pinned in this file as in `pyproject.toml`.
---
minimum_pre_commit_version: 3.3.0 # Specifies the minimum version of pre-commit required for this configuration
default_install_hook_types: [pre-commit, commit-msg] # Default hook types to install if not specified in individual hooks
default_stages: [pre-commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace # Removes trailing whitespaces from lines
- id: end-of-file-fixer # Ensures files end with a newline
- id: check-executables-have-shebangs # Checks executables have a proper shebang
- id: mixed-line-ending # Detects mixed line endings (CRLF/LF)
args: ['-f=lf'] # Forces files to use LF line endings
- id: double-quote-string-fixer # Converts single quotes to double quotes in strings

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.280
hooks:
- id: ruff # Runs ruff linter (replaces flake8)
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
hooks:
- id: reorder-python-imports # Reorders Python imports to a standard format (replaces isort)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy # Runs mypy for Python type checking
additional_dependencies: ['types-all']

- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.6.0
hooks:
- id: conventional-precommit-linter # Lints commit messages for conventional format
stages: [commit-msg]

- repo: https://github.com/psf/black
rev: '23.7.0'
hooks:
- id: black # Formats Python code using black

- repo: https://github.com/pylint-dev/pylint
rev: v2.17.5
hooks:
- id: pylint # Runs pylint on Python code
31 changes: 19 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
FROM node:current-bullseye-slim
FROM node:18-bullseye-slim

# Setting environment variables
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

ADD requirements.txt /tmp/requirements.txt
# Install Python and pip
RUN : \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
python3-pip \
python3-setuptools \
&& pip3 install --no-cache-dir --upgrade pip \
&& rm -rf /var/lib/apt/lists/* \
&& :

RUN apt-get update \
&& apt-get install -y python3-pip \
&& pip3 install --upgrade pip \
&& pip3 install -r /tmp/requirements.txt

RUN rm /tmp/requirements.txt
# Install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt

# Install Node.js dependencies
RUN npm i -g @shogobg/[email protected]

ADD sync_issue.py /sync_issue.py
ADD sync_pr.py /sync_pr.py
ADD sync_to_jira.py /sync_to_jira.py
ADD test_sync_to_jira.py /test_sync_to_jira.py
# Copy Python scripts
WORKDIR /app
COPY sync_issue.py sync_pr.py sync_to_jira.py test_sync_to_jira.py /

# Define the entrypoint
ENTRYPOINT ["/usr/bin/python3", "/sync_to_jira.py"]
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[tool.black]
line-length = 120 # The maximum line length for Python code formatting
skip-string-normalization = true # Avoids converting single quotes to double quotes in strings (pre-commit hook enforces single quotes in Python code)

[tool.ruff]
line-length = 120 # Specifies the maximum line length for ruff checks
select = ['E', 'F', 'W'] # Types of issues ruff should check for
target-version = "py38" # Specifies the target Python version for ruff checks

[tool.mypy]
disallow_incomplete_defs = false # Disallows defining functions with incomplete type annotations
disallow_untyped_defs = false # Disallows defining functions without type annotations or with incomplete type annotations
exclude = '^venv/' # Paths to ignore during type checking
ignore_missing_imports = true # Suppress error messages about imports that cannot be resolved
python_version = "3.8" # Specifies the Python version used to parse and check the target program
warn_no_return = true # Shows errors for missing return statements on some execution paths
warn_return_any = true # Shows a warning when returning a value with type Any from a function declared with a non- Any return type

[tool.pylint]
[tool.pylint.MASTER]
ignore-paths = ["tests/.*"] # Paths to ignore during linting
[tool.pylint.'BASIC']
variable-rgx = "[a-z_][a-z0-9_]{1,30}$" # Variable names must start with a lowercase letter or underscore, followed by any combination of lowercase letters, numbers, or underscores, with a total length of 2 to 30 characters.
[tool.pylint.'MESSAGES CONTROL']
disable = [
"duplicate-code", # R0801: Similar lines in %s files
"fixme", # W0511: Used when TODO/FIXME is encountered
"import-error", # E0401: Used when pylint has been unable to import a module
"import-outside-toplevel", # E0402: Imports should usually be on top of the module
"logging-fstring-interpolation", # W1202: Use % formatting in logging functions and pass the % parameters as arguments
"missing-class-docstring", # C0115: Missing class docstring
"missing-function-docstring", # C0116: Missing function or method docstring
"missing-module-docstring", # C0114: Missing module docstring
"no-name-in-module", # W0611: Used when a name cannot be found in a module
"too-few-public-methods", # R0903: Too few public methods of class
"too-many-branches", # R0912: Too many branches
"too-many-locals", # R0914: Too many local variables
"too-many-return-statements", # R0911: Too many return statements
"too-many-statements", # R0915: Too many statements
"ungrouped-imports", # C0412: Imports should be grouped by packages
]
[tool.pylint.'FORMAT']
max-line-length = 120 # Specifies the maximum line length for pylint checks
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jira>=3.0.1<3.1.0
PyGithub>=1.55<1.56
jira>=3.0.1,<3.1.0
PyGithub>=1.55,<1.56
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 8f1ae0f

Please sign in to comment.