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

Python 3.9 error: TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' #2171

Closed
chennin opened this issue Mar 6, 2024 · 4 comments · Fixed by #2183
Closed
Assignees
Labels
bug Staged Feature Complete and in Testing for Next Release
Milestone

Comments

@chennin
Copy link
Contributor

chennin commented Mar 6, 2024

Running from source wiki currently states (Dec 18, 2023 revision) that EDMC "will no longer work under Python 3.8 or earlier". However, EDMC does not run on 3.9 either.

Traceback (most recent call last):
  File "/data/./EDMarketConnector.py", line 61, in <module>
    import killswitch
  File "/data/killswitch.py", line 20, in <module>
    import config
  File "/data/config/__init__.py", line 486, in <module>
    config = get_config()
  File "/data/config/__init__.py", line 480, in get_config
    from .linux import LinuxConfig
  File "/data/config/linux.py", line 17, in <module>
    class LinuxConfig(AbstractConfig):
  File "/data/config/linux.py", line 25, in LinuxConfig
    def __init__(self, filename: str | None = None) -> None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Repro'd by checking out the code and git checkout stable (tag: Release/5.10.1), then podman run -it --rm -v $PWD:/data python:3.9 bash, then in the container: cd /data; pip install -r requirements.txt; python ./EDMarketConnector.py.

Also reported on ED Community Discord.

str | None syntax was apparently added in 3.10, though I don't have a source other than StackOverflow.

@chennin chennin added bug unconfirmed An unconfirmed bug labels Mar 6, 2024
@Athanasius
Copy link
Contributor

Yeah, that's just a wiki update being necessary. The thing to note really is the 'targeted against'. That means no actual testing of prior versions, so there should be no real expectation of it working.

@bgol
Copy link
Contributor

bgol commented Mar 6, 2024

Yes, added with 3.10: Allow writing union types as X | Y

@Rixxan Rixxan added this to the 5.11.0 milestone Mar 14, 2024
@Rixxan
Copy link
Contributor

Rixxan commented Mar 23, 2024

@chennin please try the following:

Change the imports and files in config/linux.py to include:

"""
linux.py - Linux config implementation.

Copyright (c) EDCD, All Rights Reserved
Licensed under the GNU General Public License.
See LICENSE file.
"""
from __future__ import annotations

import os
import pathlib
import sys
from configparser import ConfigParser
from config import AbstractConfig, appname, logger

assert sys.platform == 'linux'

I think we just forgot to add a future annotation there.

@Rixxan Rixxan self-assigned this Mar 23, 2024
@chennin
Copy link
Contributor Author

chennin commented Mar 24, 2024

Yes, that certainly moves past the unsupported operand error

@Rixxan Rixxan linked a pull request Mar 30, 2024 that will close this issue
@Rixxan Rixxan added Staged Feature Complete and in Testing for Next Release and removed awaiting feedback unconfirmed An unconfirmed bug labels Apr 5, 2024
@Rixxan Rixxan closed this as completed Apr 16, 2024
@github-project-automation github-project-automation bot moved this to Closed (Fixed) in Bug Triage Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Staged Feature Complete and in Testing for Next Release
Projects
Status: Closed (Fixed)
Development

Successfully merging a pull request may close this issue.

4 participants