Skip to content

Commit

Permalink
Merge pull request #1737 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruchamahabal authored May 1, 2024
2 parents 595c369 + 6d5c118 commit 9275519
Show file tree
Hide file tree
Showing 286 changed files with 4,271 additions and 4,241 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Root editor config file
root = true

# Common settings
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# js indentation settings
[{*.js,*.vue,*.css,*.scss,*.html}]
indent_style = tab
indent_size = 4
max_line_length = 99
37 changes: 0 additions & 37 deletions .flake8

This file was deleted.

8 changes: 7 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@
76c895a6c659356151433715a1efe9337e348c11

# bulk formatting
b55d6e27af6bd274dfa47e66a3012ddec68ce798
b55d6e27af6bd274dfa47e66a3012ddec68ce798

# js, scss prettier formatting
4a224b988a254a053e9c49cd101cd67d433aed90

# python ruff formatting
7b0d00220047545d3d18650235dac9cebe0d2bca
73 changes: 0 additions & 73 deletions .github/helper/.flake8_strict

This file was deleted.

11 changes: 4 additions & 7 deletions .github/helper/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ def uri_validator(x):
result = urlparse(x)
return all([result.scheme, result.netloc, result.path])


def docs_link_exists(body):
for line in body.splitlines():
for word in line.split():
if word.startswith('http') and uri_validator(word):
if word.startswith("http") and uri_validator(word):
parsed_url = urlparse(word)
if parsed_url.netloc == "github.com":
parts = parsed_url.path.split('/')
parts = parsed_url.path.split("/")
if len(parts) == 5 and parts[1] == "frappe" and parts[2] == "hrms":
return True
elif parsed_url.netloc == "frappehr.com":
Expand All @@ -30,11 +31,7 @@ def docs_link_exists(body):
head_sha = (payload.get("head") or {}).get("sha")
body = (payload.get("body") or "").lower()

if (title.startswith("feat")
and head_sha
and "no-docs" not in body
and "backport" not in body
):
if title.startswith("feat") and head_sha and "no-docs" not in body and "backport" not in body:
if docs_link_exists(body):
print("Documentation Link Found. You're Awesome! 🎉")

Expand Down
34 changes: 21 additions & 13 deletions .github/helper/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
import sys

errors_encounter = 0
pattern = re.compile(r"_\(([\"']{,3})(?P<message>((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P<py_context>((?!\5).)*)\5)*(\s*,(\s*?.*?\n*?)*(,\s*([\"'])(?P<js_context>((?!\11).)*)\11)*)*\)")
pattern = re.compile(
r"_\(([\"']{,3})(?P<message>((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P<py_context>((?!\5).)*)\5)*(\s*,(\s*?.*?\n*?)*(,\s*([\"'])(?P<js_context>((?!\11).)*)\11)*)*\)"
)
words_pattern = re.compile(r"_{1,2}\([\"'`]{1,3}.*?[a-zA-Z]")
start_pattern = re.compile(r"_{1,2}\([f\"'`]{1,3}")
f_string_pattern = re.compile(r"_\(f[\"']")
starts_with_f_pattern = re.compile(r"_\(f")

# skip first argument
files = sys.argv[1:]
files_to_scan = [_file for _file in files if _file.endswith(('.py', '.js'))]
files_to_scan = [_file for _file in files if _file.endswith((".py", ".js"))]

for _file in files_to_scan:
with open(_file, 'r') as f:
print(f'Checking: {_file}')
with open(_file, "r") as f:
print(f"Checking: {_file}")
file_lines = f.readlines()
for line_number, line in enumerate(file_lines, 1):
if 'frappe-lint: disable-translate' in line:
if "frappe-lint: disable-translate" in line:
continue

start_matches = start_pattern.search(line)
Expand All @@ -28,33 +30,39 @@
has_f_string = f_string_pattern.search(line)
if has_f_string:
errors_encounter += 1
print(f'\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}')
print(
f"\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}"
)
continue
else:
continue

match = pattern.search(line)
error_found = False

if not match and line.endswith((',\n', '[\n')):
if not match and line.endswith((",\n", "[\n")):
# concat remaining text to validate multiline pattern
line = "".join(file_lines[line_number - 1:])
line = line[start_matches.start() + 1:]
line = "".join(file_lines[line_number - 1 :])
line = line[start_matches.start() + 1 :]
match = pattern.match(line)

if not match:
error_found = True
print(f'\nTranslation syntax error at line number {line_number}\n{line.strip()[:100]}')
print(f"\nTranslation syntax error at line number {line_number}\n{line.strip()[:100]}")

if not error_found and not words_pattern.search(line):
error_found = True
print(f'\nTranslation is useless because it has no words at line number {line_number}\n{line.strip()[:100]}')
print(
f"\nTranslation is useless because it has no words at line number {line_number}\n{line.strip()[:100]}"
)

if error_found:
errors_encounter += 1

if errors_encounter > 0:
print('\nVisit "https://frappeframework.com/docs/user/en/translations" to learn about valid translation strings.')
print(
'\nVisit "https://frappeframework.com/docs/user/en/translations" to learn about valid translation strings.'
)
sys.exit(1)
else:
print('\nGood To Go!')
print("\nGood To Go!")
39 changes: 22 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,32 @@ repos:
- id: check-merge-conflict
- id: check-ast

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: flake8
additional_dependencies: [
'flake8-bugbear',
]
args: ['--config', '.github/helper/.flake8_strict']
exclude: ".*setup.py$"
- id: prettier
types_or: [javascript, vue, css, scss]
# Ignore any files that might contain jinja / bundles
exclude: |
(?x)^(
hrms/public/dist/.*|
.*node_modules.*|
.*boilerplate.*|
hrms/templates/includes/.*|
hrms/hr/doctype/employee_promotion/employee_promotion.js|
hrms/hr/doctype/employee_transfer/employee_transfer.js|
hrms/payroll/doctype/salary_structure/salary_structure.js|
)$
- repo: https://github.com/adityahase/black
rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: black
additional_dependencies: ['click==8.0.4']
- id: ruff
name: "Run ruff linter and apply fixes"
args: ["--fix"]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
exclude: ".*setup.py$"
- id: ruff-format
name: "Format Python code"

ci:
autoupdate_schedule: weekly
Expand Down
36 changes: 18 additions & 18 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
parserPreset: "conventional-changelog-conventionalcommits",
rules: {
'subject-empty': [2, 'never'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
"subject-empty": [2, "never"],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"type-enum": [
2,
'always',
"always",
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'patch',
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"patch",
],
],
},
Expand Down
10 changes: 3 additions & 7 deletions hrms/controllers/tests/test_employee_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def setUpClass(cls):
to_date=getdate() + timedelta(weeks=5),
)

test_employee = frappe.get_doc(
"Employee", make_employee("test@gopher.io", company="_Test Company")
)
test_employee = frappe.get_doc("Employee", make_employee("test@gopher.io", company="_Test Company"))

# Attach the holiday list to employee
test_employee.holiday_list = test_holiday_list.name
Expand Down Expand Up @@ -102,9 +100,7 @@ def test_is_holiday(self):
self.assertTrue("test holiday1" in descriptions)

def test_birthday_reminders(self):
employee = frappe.get_doc(
"Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]
)
employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0])
employee.date_of_birth = "1992" + frappe.utils.nowdate()[4:]
employee.company_email = "test@example.com"
employee.company = "_Test Company"
Expand Down Expand Up @@ -133,7 +129,7 @@ def test_work_anniversary_reminders(self):
send_work_anniversary_reminders,
)

emp = make_employee(
make_employee(
"test_emp_work_anniversary@gmail.com",
company="_Test Company",
date_of_joining=frappe.utils.add_years(getdate(), -2),
Expand Down
Loading

0 comments on commit 9275519

Please sign in to comment.