Skip to content

Commit

Permalink
Merge pull request #322 from Carreau/no-six
Browse files Browse the repository at this point in the history
More removal of six.
  • Loading branch information
Carreau authored Mar 25, 2024
2 parents 41733ec + 4a004f8 commit 82a3fe6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion etc/pyflyby/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
email_mime_image, email_mime_multipart,
email_mime_text, http_client, map,
queue, zip)
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode
from six.moves.urllib.request import urlopen
import smtplib
from smtplib import (SMTP, SMTPAuthenticationError,
Expand Down
5 changes: 2 additions & 3 deletions lib/python/pyflyby/_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
reformat_import_statements)
from pyflyby._importstmt import Import
from pyflyby._log import logger
import six

# These are comm targets that the frontend (lab/notebook) is expected to
# open. At this point, we handle only missing imports and
Expand Down Expand Up @@ -67,7 +66,7 @@ def initialize_comms():


def remove_comms():
for target_name, comm in six.iteritems(comms):
for target_name, comm in comms.items():
comm.close()
logger.debug("Closing comm for " + target_name)

Expand All @@ -87,7 +86,7 @@ def send_comm_message(target_name, msg):

def comm_close_handler(comm, message):
comm_id = message["comm_id"]
for target, comm in six.iterkeys(comms):
for target, comm in comms.keys():
if comm.comm_id == comm_id:
comms.pop(target)

Expand Down
2 changes: 1 addition & 1 deletion lib/python/pyflyby/_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import __future__
import ast
import operator
from six.moves import reduce
from functools import reduce
import warnings

from pyflyby._util import cached_attribute
Expand Down
3 changes: 1 addition & 2 deletions lib/python/pyflyby/_importclns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from collections import defaultdict
from functools import total_ordering
import six

from pyflyby._flags import CompilerFlags
from pyflyby._idents import dotted_prefixes, is_identifier
Expand Down Expand Up @@ -567,7 +566,7 @@ def iteritems(self):
return self._data.items()

def iterkeys(self):
return six.iterkeys(self._data)
return iter(self._data.keys())

def keys(self):
return self._data.keys()
Expand Down
3 changes: 1 addition & 2 deletions lib/python/pyflyby/_importdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from collections import defaultdict
import os
import re
import six

from pyflyby._file import Filename, expand_py_files_from_args, UnsafeFilenameError
from pyflyby._idents import dotted_prefixes
Expand Down Expand Up @@ -560,7 +559,7 @@ def by_fullname_or_import_as(self):
for prefix in dotted_prefixes(imp.fullname)[:-1]:
d[prefix].add(Import.from_parts(prefix, prefix))
return dict( (k, tuple(sorted(v - set(self.forget_imports.imports))))
for k, v in six.iteritems(d))
for k, v in d.items())

def __repr__(self):
printed = self.pretty_print()
Expand Down
10 changes: 6 additions & 4 deletions lib/python/pyflyby/_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@


import ast
import builtins
from contextlib import contextmanager
import errno
import inspect
import os
import operator
import re
import subprocess
import sys

import six
from six.moves import builtins

from pyflyby._autoimp import (LoadSymbolError, ScopeStack, auto_eval,
auto_import,
Expand All @@ -37,6 +37,8 @@
__original__ = None # for pyflakes


get_method_self = operator.attrgetter('__self__')

# TODO: also support arbitrary code (in the form of a lambda and/or
# assignment) as new way to do "lazy" creations, e.g. foo = a.b.c(d.e+f.g())

Expand Down Expand Up @@ -2098,7 +2100,7 @@ def _enable_prun_hook(self, ip):
# Tested with IPython 1.0, 1.1, 1.2, 2.0, 2.1, 2.2, 2.3, 2.4, 3.0,
# 3.1, 3.2, 4.0.
line_magics = ip.magics_manager.magics['line']
execmgr = six.get_method_self(line_magics['prun'])#.im_self
execmgr = get_method_self(line_magics['prun'])#.im_self
if hasattr(execmgr, "_run_with_profiler"):
@self._advise(execmgr._run_with_profiler)
def run_with_profiler_with_autoimport(code, opts, namespace):
Expand Down Expand Up @@ -2303,7 +2305,7 @@ def debugger_with_autoimport(*args, **kwargs):
# Tested with IPython 1.0, 1.1, 1.2, 2.0, 2.1, 2.2, 2.3, 2.4, 3.0,
# 3.1, 3.2, 4.0, 5.8.
line_magics = ip.magics_manager.magics['line']
execmgr = six.get_method_self(line_magics['debug'])
execmgr = get_method_self(line_magics['debug'])
if hasattr(execmgr, "_run_with_debugger"):
@self._advise(execmgr._run_with_debugger)
def run_with_debugger_with_autoimport(code, code_ns,
Expand Down
2 changes: 1 addition & 1 deletion lib/python/pyflyby/_livepatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __livepatch__(self, old, do_livepatch):
import time
import types

from six.moves import reload_module
from importlib import reload as reload_module

import inspect
from pyflyby._log import logger
Expand Down
2 changes: 1 addition & 1 deletion lib/python/pyflyby/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@



import builtins
from contextlib import contextmanager
import logging
from logging import Handler, Logger
import os
from six.moves import builtins
import sys


Expand Down

0 comments on commit 82a3fe6

Please sign in to comment.