SalamLang / Salam

Salam Language: The inaugural coding language for Persian and Arabic speakers, inspired by the word salam meaning peace. With a user-friendly approach, it provides an accessible coding experience, promoting collaboration and simplicity for local developers.
https://www.salamlang.ir
GNU General Public License v3.0
12 stars 8 forks source link

pre-commit yaml linter python code is not supporting persian yaml files (not supporting utf8) #265

Open BaseMax opened 3 weeks ago

BaseMax commented 3 weeks ago

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 445: character maps to

image

C:\Users\MAX\Salam>git commit -m "lint and format on all yaml files"
identity.................................................................Passed
- hook id: identity
- duration: 0.39s

config/language.yaml
config/layout/attribute/type.yaml
config/layout/attribute/style/type.yaml
config/layout/type.yaml
config/layout/attribute/style/state.yaml
config/layout/attribute/style/global_value.yaml
config/layout/attribute/style/value.yaml
config/type.yaml

Check hooks apply to the repository..................(no files to check)Skipped
black................................................(no files to check)Skipped
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check that executables have shebangs.....................................Passed
check illegal windows names..........................(no files to check)Skipped
check for merge conflicts................................................Passed
check that scripts with shebangs are executable..........................Passed
check vcs permalinks.....................................................Passed
check yaml...............................................................Passed
detect destroyed symlinks................................................Passed
detect aws credentials...................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
fix utf-8 byte order marker..............................................Passed
forbid submodules....................................(no files to check)Skipped
mixed line ending........................................................Passed
trim trailing whitespace.................................................Passed
codespell................................................................Passed
Markdown Link Check..................................(no files to check)Skipped
Run markdownlint.....................................(no files to check)Skipped
Run yamllint.............................................................Failed
- hook id: yamllint
- exit code: 1

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Scripts\yamllint.EXE\__main__.py", line 7, in <module>
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Lib\site-packages\yamllint\cli.py", line 223, in run
    problems = linter.run(f, conf, filepath)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Lib\site-packages\yamllint\linter.py", line 232, in run
    content = input.read()
              ^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 61: character maps to <undefined>
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Scripts\yamllint.EXE\__main__.py", line 7, in <module>
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Lib\site-packages\yamllint\cli.py", line 223, in run
    problems = linter.run(f, conf, filepath)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MAX\.cache\pre-commit\repol2sbu8ft\py_env-python3\Lib\site-packages\yamllint\linter.py", line 232, in run
    content = input.read()
              ^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2032.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 445: character maps to <undefined>

clang-format.........................................(no files to check)Skipped
BaseMax commented 3 weeks ago

I changed that line and added encoding option as following: with open(file, newline='', encoding='utf-8') as f:

and the problem has been fixed.

We need to hack python yamllint or send a merge request to that package.

BaseMax commented 3 weeks ago

The patch has been sent.

https://github.com/adrienverge/yamllint/pull/696