Skip to content

Commit 752fe75

Browse files
author
Release Manager
committed
gh-35697: cylint: remove imports in misc/ <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description remove unused imports found by cython-lint in `misc` folder also one unused variable is removed <!-- Describe your changes here in detail. --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35697 Reported by: Frédéric Chapoton Reviewer(s): Matthias Köppe
2 parents e83e419 + 5c1ec45 commit 752fe75

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

src/sage/misc/binary_tree.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ cdef object binary_tree_get(binary_tree_node *self, int key):
6363

6464
cdef object binary_tree_delete(binary_tree_node *self, int key):
6565
cdef object t
66-
cdef binary_tree_node *cur
6766
if self.key > key:
6867
if self.left == NULL:
6968
return None

src/sage/misc/fpickle.pyx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Function pickling
55
66
REFERENCE: The python cookbook.
77
"""
8-
98
import copyreg
109
import pickle
1110
import sys
@@ -91,6 +90,7 @@ def pickle_function(func):
9190
"""
9291
return pickle.dumps(func.__code__)
9392

93+
9494
def unpickle_function(pickled):
9595
"""
9696
Unpickle a pickled function.
@@ -106,15 +106,16 @@ def unpickle_function(pickled):
106106
return types.FunctionType(recovered, globals())
107107

108108

109-
110109
def call_pickled_function(fpargs):
111110
import sage.all
112-
from sage.misc.fpickle import unpickle_function
111+
from sage.misc.fpickle import unpickle_function # used below
113112
(fp, (args, kwds)) = fpargs
114-
f = eval("unpickle_function(fp)", sage.all.__dict__, {'fp':fp})
115-
res = eval("f(*args, **kwds)",sage.all.__dict__, {'args':args, 'kwds':kwds, 'f':f})
113+
f = eval("unpickle_function(fp)", sage.all.__dict__, {'fp': fp})
114+
res = eval("f(*args, **kwds)", sage.all.__dict__,
115+
{'args': args, 'kwds': kwds, 'f': f})
116116
return ((args, kwds), res)
117117

118+
118119
# The following four methods are taken from twisted.persisted.styles - the
119120
# import of twisted.persisted.styles takes a long time and we do not use
120121
# most functionality it provides
@@ -128,11 +129,11 @@ def pickleMethod(method):
128129

129130

130131
def unpickleMethod(im_name,
131-
__self__,
132-
im_class):
132+
__self__,
133+
im_class):
133134
'support function for copyreg to unpickle method refs'
134135
try:
135-
unbound = getattr(im_class,im_name)
136+
unbound = getattr(im_class, im_name)
136137
if __self__ is None:
137138
return unbound
138139

@@ -154,21 +155,25 @@ def unpickleMethod(im_name,
154155
__self__)
155156
return bound
156157

158+
157159
copyreg.pickle(types.MethodType,
158-
pickleMethod,
159-
unpickleMethod)
160+
pickleMethod,
161+
unpickleMethod)
160162

161163
oldModules = {}
162164

165+
163166
def pickleModule(module):
164167
'support function for copyreg to pickle module refs'
165168
return unpickleModule, (module.__name__,)
166169

170+
167171
def unpickleModule(name):
168172
'support function for copyreg to unpickle module refs'
169173
if name in oldModules:
170174
name = oldModules[name]
171-
return __import__(name,{},{},'x')
175+
return __import__(name, {}, {}, 'x')
176+
172177

173178
copyreg.pickle(types.ModuleType,
174179
pickleModule,

src/sage/misc/misc_c.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ AUTHORS:
2323
# https://www.gnu.org/licenses/
2424
# ****************************************************************************
2525

26-
import sys
27-
2826
from cpython.sequence cimport *
2927
from cpython.list cimport *
3028
from cpython.tuple cimport *

src/sage/misc/parser.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ AUTHOR:
2020
# https://www.gnu.org/licenses/
2121
# ***************************************************************************
2222

23-
from libc.string cimport strchr
24-
from cpython.bytes cimport PyBytes_FromStringAndSize
2523
from cpython.list cimport PyList_Append
2624

2725
import math
@@ -1095,4 +1093,4 @@ cdef class LookupNameMaker:
10951093
except KeyError:
10961094
if self.fallback is not None:
10971095
return self.fallback(name)
1098-
raise NameError("Unknown variable: '{}'".format(name))
1096+
raise NameError(f"Unknown variable: '{name}'")

src/sage/misc/randstate.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ import os
419419
import time
420420
import weakref
421421
import random as _random
422-
import sys
423422

424423
use_urandom = False
425424
# Check whether os.urandom() works.
@@ -713,7 +712,6 @@ cdef class randstate:
713712
if self._gap_saved_seed is not None:
714713
mersenne_seed, classic_seed = self._gap_saved_seed
715714
else:
716-
import sage.rings.integer_ring as integer_ring
717715
from sage.rings.integer_ring import ZZ
718716
seed = ZZ.random_element(long(1)<<128)
719717
classic_seed = seed

src/sage/misc/session.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ AUTHOR:
6161
# Copyright (C) 2007,2010 William Stein <[email protected]>
6262
# Distributed under the terms of the GNU General Public License (GPL)
6363
# The full text of the GPL is available at:
64-
# http://www.gnu.org/licenses/
64+
# https://www.gnu.org/licenses/
6565
#############################################################################
6666

6767
# Standard python imports
6868
import builtins
69-
import os
7069
import types
7170

7271
# We want the caller's locals, but locals() is emulated in Cython

src/sage/misc/weak_dict.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,13 @@ See :trac:`13394` for a discussion of some of the design considerations.
118118
# https://www.gnu.org/licenses/
119119
# ****************************************************************************
120120

121-
import weakref
122121
from weakref import KeyedRef
123122
from copy import deepcopy
124123

125124
from cpython.dict cimport PyDict_SetItem, PyDict_Next
126125
from cpython.tuple cimport PyTuple_GET_SIZE, PyTuple_New
127126
from cpython.weakref cimport PyWeakref_NewRef
128-
from cpython.object cimport PyObject_Hash
129-
from cpython.ref cimport Py_INCREF, Py_XINCREF, Py_XDECREF
127+
from cpython.ref cimport Py_INCREF
130128
from sage.cpython.dict_del_by_value cimport *
131129

132130
from sage.misc.superseded import deprecation

0 commit comments

Comments
 (0)