GithubHelp home page GithubHelp logo

Comments (5)

umlaeute avatar umlaeute commented on June 4, 2024

a more complete solution would be to just drop all those occurences of if sys.version_info <= (3,0)

from canmatrix.

umlaeute avatar umlaeute commented on June 4, 2024

also note that

DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in Python 3.12. Use ConfigParser directly instead.

since Python3.12 has arrived, this needs to be handled somehow:

--- python-canmatrix.orig/versioneer.py
+++ python-canmatrix/versioneer.py
@@ -336,9 +336,9 @@
     # configparser.NoOptionError (if it lacks "VCS="). See the docstring at
     # the top of versioneer.py for instructions on writing your setup.cfg .
     setup_cfg = os.path.join(root, "setup.cfg")
-    parser = configparser.SafeConfigParser()
+    parser = configparser.ConfigParser()
     with open(setup_cfg, "r") as f:
-        parser.readfp(f)
+        parser.read_file(f)
     VCS = parser.get("versioneer", "VCS")  # mandatory
 
     def get(parser, name):

this patch requires Python>=3.2 which is probably acceptable (or not)

from canmatrix.

umlaeute avatar umlaeute commented on June 4, 2024

in my original post, i missed that there are a few imports of the past library (which is part of future),

so here's a more complete patch to get rid of future:

Index: python-canmatrix-1.0~github/setup.py
===================================================================
--- python-canmatrix-1.0~github.orig/setup.py
+++ python-canmatrix-1.0~github/setup.py
@@ -83,7 +83,6 @@ setup(
         "attrs>=19.2.0",
         "click",
         "enum34; python_version < '3.4'",
-        "future",
         "importlib-metadata; python_version < '3.8'",
         "six",
         "typing; python_version < '3.5'",
Index: python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/sym.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
@@ -100,11 +100,7 @@ def format_float(f):  # type: (typing.An
 
 def create_signal(db, signal):  # type: (canmatrix.CanMatrix, canmatrix.Signal) -> str
     output = ""
-    if sys.version_info > (3, 0):
-        quote_name = not signal.name.isidentifier()
-    else:
-        from future.utils import isidentifier
-        quote_name = not isidentifier(signal.name)
+    quote_name = not signal.name.isidentifier()
     if quote_name:
         output += 'Var="%s" ' % signal.name
     else:
Index: python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/canmatrix.py
+++ python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
@@ -40,7 +40,6 @@ import warnings
 from builtins import *
 
 import attr
-from past.builtins import basestring
 from six.moves import zip_longest
 
 import canmatrix.copy
@@ -432,7 +431,7 @@ class Signal(object):
             if not (self.min <= value <= self.max):
                 value = self.min
 
-        if isinstance(value, basestring):
+        if isinstance(value, str):
             for value_key, value_string in self.values.items():
                 if value_string == value:
                     value = value_key
Index: python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/xls.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
@@ -30,7 +30,6 @@ import logging
 import typing
 from builtins import *
 
-import past.builtins
 import xlrd
 import xlwt
 
@@ -540,7 +539,7 @@ def load(file, **options):
         unit = ""
 
         factor = sh.cell(row_num, index['function']).value
-        if isinstance(factor, past.builtins.basestring):
+        if isinstance(factor, str):
             factor = factor.strip()
             if " " in factor and factor[0].isdigit():
                 (factor, unit) = factor.strip().split(" ", 1)
Index: python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/yaml.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
@@ -30,7 +30,6 @@ import typing
 from builtins import *
 
 import yaml
-from past.builtins import long, unicode
 
 import canmatrix
 
@@ -43,8 +42,6 @@ except ImportError:
 representers = False
 try:
     yaml.add_representer(int, SafeRepresenter.represent_int)
-    yaml.add_representer(long, SafeRepresenter.represent_long)
-    yaml.add_representer(unicode, SafeRepresenter.represent_unicode)
     yaml.add_representer(str, SafeRepresenter.represent_unicode)
     yaml.add_representer(list, SafeRepresenter.represent_list)
     representers = True
@@ -67,7 +64,7 @@ def dump(db, f, **options):  # type: (ca
 
     # f = open(filename, "w")
     if representers:
-        f.write(unicode(yaml.dump(new_db)))
+        f.write(yaml.dump(new_db))
     else:
         f.write(yaml.dump(new_db).encode('utf8'))
 
Index: python-canmatrix-1.0~github/mypy.ini
===================================================================
--- python-canmatrix-1.0~github.orig/mypy.ini
+++ python-canmatrix-1.0~github/mypy.ini
@@ -34,5 +34,5 @@ ignore_errors = True
 ignore_errors = True
 
 # other settings:
-[mypy-xlsxwriter,past,past.builtins,pathlib2]
+[mypy-xlsxwriter,pathlib2]
 ignore_missing_imports = True

notes

  • the patch in this comment is only concerned about the future module (and not about the configparser in the other comment)
  • i've replaced isinstance(x, basestring) with isinstance(x, str), as basestring was typically used to check whether a value was either str or unicode (which are both str in Py3). However, IIRC basestring is also the base class for bytes (at least isinstance(b'foo', past.builtins.basestring) yields True), so the new test might miss some cases...

from canmatrix.

ebroecker avatar ebroecker commented on June 4, 2024

Hi @umlaeute ,

thanks for your help.

And yes, you are right.
I created 2 pull requests for your patches:
#744
#745

Thanks again

from canmatrix.

umlaeute avatar umlaeute commented on June 4, 2024

sorry to have created additional work.

i could (and would) of course have done the PRs myself, but wanted to get your feedback first to see if i was on the right track (and it was easier for my actual workflow (while preparing the Debian packages) to just paste the diffs for now)

from canmatrix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.