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

TypeError when using c_formatter_42 in Python 3.11.6 #73

Open
axellee1994 opened this issue Nov 30, 2023 · 1 comment
Open

TypeError when using c_formatter_42 in Python 3.11.6 #73

axellee1994 opened this issue Nov 30, 2023 · 1 comment

Comments

@axellee1994
Copy link

axellee1994 commented Nov 30, 2023

  • I've installed c_formatter_42 using pip3 install c-formatter-42 in Python 3.11.6. The installation was successful without any errors.

  • However, when I try to use the package, I get a TypeError with the following traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/__main__.py", line 18, in <module>
    from c_formatter_42.run import run_all
  File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/run.py", line 14, in <module>
    from c_formatter_42.formatters.clang_format import clang_format
  File "/opt/homebrew/lib/python3.11/site-packages/c_formatter_42/formatters/clang_format.py", line 21, in <module>
    DATA_DIR = Path(c_formatter_42.data.__file__).parent
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 871, in __new__
    self = cls._from_parts(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 509, in _from_parts
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 493, in _parse_args
    a = os.fspath(a)
        ^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

42-c-format: Please read README and check requirements.
  • The error seems to come from the c_formatter_42 package's source code. It's trying to get the __file__ attribute of the c_formatter_42.data module, but this attribute seems to be None.
  • I'm using macOS and Visual Studio Code as my code editor. I've followed all the setup instructions in the README, including setting the correct Python interpreter in VS Code and installing the keyhr.42-c-format extension.
  • I've checked the Python version, reinstalled the package, and read the README, but none of these steps have resolved the issue.

Can you please help me understand what's going wrong?

@cacharle
Copy link
Collaborator

cacharle commented Dec 1, 2023

It's weird, with almost the same version of Python, I have no problem running it.

❯ python
Python 3.11.5 (main, Aug 24 2023, 15:23:30) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import c_formatter_42.data
>>> print(c_formatter_42.data.__file__)
/.../c_formatter_42/c_formatter_42/data/__init__.py
❯ echo 'int main() { return 0; }' | c_formatter_42
int     main(void)
{
        return (0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants