Skip to content

Commit

Permalink
Merge pull request #195 from twisted/drop-support-for-py35
Browse files Browse the repository at this point in the history
Drop support for py35
  • Loading branch information
graingert authored Mar 1, 2021
2 parents eed7049 + a3e10c1 commit b5c302a
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 67 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ jobs:
with:
python-version: pypy3

- name: Set Up Python 3.5
uses: actions/setup-python@v2
with:
python-version: 3.5

- name: Set Up Python 3.6
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -81,7 +76,7 @@ jobs:
TOX_SKIP_ENV: ${{ matrix.cfg.tox-skip-env }}
run:
tox --parallel=all
-e'py{35,36,37,38,39,py3}-test-{twlatest,twtrunk},publishcov,py39-linters,release'
-e'py{36,37,38,39,py3}-test-{twlatest,twtrunk},publishcov,py39-linters,release'

- name: upload dist
uses: actions/upload-artifact@v2
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
rev: v2.10.0
hooks:
- id: pyupgrade
args: ["--py3-plus"]
args: ["--py36-plus"]

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ["--target-version", "py35"]
args: ["--target-version", "py36"]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
rev: v1.8.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
rev: v3.4.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: mixed-line-ending

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.1.2
rev: v2.2.1
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]
Expand All @@ -47,6 +47,6 @@ repos:
- --remove-unused-variables

- repo: https://github.com/mgedmin/check-manifest
rev: "0.45"
rev: "0.46"
hooks:
- id: check-manifest
2 changes: 1 addition & 1 deletion docs/source/NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
21.2.1 (unreleased)
-------------------

- Nothing changed yet.
- Dropped support for Python 3.5


21.2.0 (2021-02-28)
Expand Down
4 changes: 1 addition & 3 deletions docs/source/examples/addressbook/05_form/addressbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def coerce(self, *a, **kw):
try:
f = ldapfilter.parseFilter(val)
except ldapfilter.InvalidLDAPFilter as e:
raise annotate.InputError(
"{!r} is not a valid LDAP search filter: {}".format(val, e)
)
raise annotate.InputError(f"{val!r} is not a valid LDAP search filter: {e}")
return f


Expand Down
4 changes: 1 addition & 3 deletions docs/source/examples/addressbook/06_pretty/addressbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def coerce(self, *a, **kw):
try:
f = ldapfilter.parseFilter(val)
except ldapfilter.InvalidLDAPFilter as e:
raise annotate.InputError(
"{!r} is not a valid LDAP search filter: {}".format(val, e)
)
raise annotate.InputError(f"{val!r} is not a valid LDAP search filter: {e}")
return f


Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/client_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def onConnect(clientProtocol):
o = LDAPEntry(clientProtocol, "dc=fr")
results = yield o.search()
data = "".join([result.getLDIF() for result in results])
log.msg("LDIF formatted results:\n{}".format(data))
log.msg(f"LDIF formatted results:\n{data}")


def onError(err, reactor):
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/client_paged_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def onConnect(client, args):
client, args, args.filter, page_size=page_size, cookie=cookie
)
count += len(results)
print("Page {}".format(page))
print(f"Page {page}")
display_results(results)
if len(cookie) == 0:
break
page += 1
print("There were {} results returned in total.".format(count))
print(f"There were {count} results returned in total.")


@defer.inlineCallbacks
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/ldaptor_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def reload_tree(self):

for employee in db_session.query(Employee):
users_tree.addChild(
"uid={}".format(employee.uid),
f"uid={employee.uid}",
{
"uid": [employee.uid],
"givenName": [employee.first_name],
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/quickstart_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def buildProtocol(self, addr):
factory.debug = True
application = service.Application("ldaptor-server")
myService = service.IServiceCollection(application)
serverEndpointStr = "tcp:{}".format(port)
serverEndpointStr = f"tcp:{port}"
e = serverFromString(reactor, serverEndpointStr)
d = e.listen(factory)
reactor.run()
2 changes: 1 addition & 1 deletion ldaptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

__license__ = "MIT"
__author__ = "The ldaptor developers"
__copyright__ = "Copyright (c) 2002-2019 {}".format(__author__)
__copyright__ = f"Copyright (c) 2002-2021 {__author__}"
10 changes: 4 additions & 6 deletions ldaptor/_scripts/ldap2dhcpconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, host, ipAddress):
def printDHCP(self, domain, prefix=""):
def output():
yield "# %s" % self.host.dn
yield "host {}.{} {{".format(self.host.name, domain)
yield f"host {self.host.name}.{domain} {{"
for mac in self.host.macAddresses:
yield "\thardware ethernet %s;" % mac
yield "\tfixed-address %s;" % self.ipAddress
Expand Down Expand Up @@ -181,8 +181,8 @@ def printDHCP(self, domain, prefix=""):
nm = my_ntoa(nm)
r = [
"# %s" % self.dn,
"subnet {} netmask {} {{".format(self.address, nm),
'\toption domain-name "{}.{}";'.format(self.name, domain),
f"subnet {self.address} netmask {nm} {{",
f'\toption domain-name "{self.name}.{domain}";',
]
if self.routers:
r.append("\toption routers %s;" % (", ".join(self.routers)))
Expand Down Expand Up @@ -322,9 +322,7 @@ def only(e, attr, default=_NO_DEFAULT):
if default is not _NO_DEFAULT:
return default
else:
raise RuntimeError(
"object {} does not have attribute {!r}.".format(e.dn, attr)
)
raise RuntimeError(f"object {e.dn} does not have attribute {attr!r}.")
else:
if len(val) != 1:
raise RuntimeError(
Expand Down
2 changes: 1 addition & 1 deletion ldaptor/_scripts/ldap2dnszones.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def formatIPAddress(name, ip):
return "{}\tIN A\t{}\n".format(name, ip)
return f"{name}\tIN A\t{ip}\n"


def formatPTR(name, ip):
Expand Down
2 changes: 1 addition & 1 deletion ldaptor/_scripts/namingcontexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def connectionMade(self):

def _printResults(self, result, host):
for context in result["namingContexts"]:
print("{}\t{}".format(host, context))
print(f"{host}\t{context}")

def _handle_bind_success(self, x):
matchedDN, serverSaslCreds = x
Expand Down
2 changes: 1 addition & 1 deletion ldaptor/attributeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __repr__(self):
values = list(self)
values.sort()
attributes = ", ".join([repr(x) for x in values])
return "{}({!r}, [{}])".format(self.__class__.__name__, self.key, attributes)
return f"{self.__class__.__name__}({self.key!r}, [{attributes}])"

def __eq__(self, other):
"""
Expand Down
2 changes: 1 addition & 1 deletion ldaptor/ldiftree.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def commit(self):
def eb_(err):
from twisted.python import log

log.msg("[ERROR] Could not commit entry: {}.".format(self.dn))
log.msg(f"[ERROR] Could not commit entry: {self.dn}.")
return False

d.addErrback(eb_)
Expand Down
4 changes: 2 additions & 2 deletions ldaptor/protocols/ldap/ldapsyntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __str__(self):
self.__doc__,
"; ".join(
[
"{} failed with {}".format(name, fail.getErrorMessage())
f"{name} failed with {fail.getErrorMessage()}"
for name, fail in self.errors
]
),
Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(self, op):
self.op = op

def __str__(self):
return "{}: {!r}".format(self.__doc__, self.op)
return f"{self.__doc__}: {self.op!r}"


class JournaledLDAPAttributeSet(attributeset.LDAPAttributeSet):
Expand Down
2 changes: 1 addition & 1 deletion ldaptor/protocols/ldap/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _whenConnected(self, fn, *a, **kw):

def _failConnection(self, reason):
self.transport.loseConnection()
raise ldaperrors.LDAPOther("Cannot connect to server.{}".format(reason))
raise ldaperrors.LDAPOther(f"Cannot connect to server.{reason}")

def _cbConnectionMade(self, proto):
self.clients.append(proto)
Expand Down
5 changes: 1 addition & 4 deletions ldaptor/protocols/pureber.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Only some BOOLEAN and INTEGER types have default values in
# this protocol definition.

import sys
from collections import UserList

from ldaptor._encoder import to_bytes, WireStrAlias
Expand Down Expand Up @@ -347,9 +346,7 @@ def inherit(self):
def __repr__(self):
identities = []
for tag, class_ in self.Identities.items():
identities.append("0x{:02x}: {}".format(tag, class_.__name__))

sys.version_info < (3, 6) and identities.sort()
identities.append(f"0x{tag:02x}: {class_.__name__}")

return (
"<"
Expand Down
10 changes: 5 additions & 5 deletions ldaptor/protocols/pureldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def __repr__(self):
return "{}(uris={}{})".format(
self.__class__.__name__,
repr([uri for uri in self.uris]),
", tag={}".format(self.tag) if self.tag != self.__class__.tag else "",
f", tag={self.tag}" if self.tag != self.__class__.tag else "",
)


Expand Down Expand Up @@ -1061,7 +1061,7 @@ def __repr__(self):
self.__class__.__name__,
repr(name),
repr(attributes),
", tag={}".format(self.tag) if self.tag != self.__class__.tag else "",
f", tag={self.tag}" if self.tag != self.__class__.tag else "",
)


Expand Down Expand Up @@ -1545,7 +1545,7 @@ def __repr__(self):
return "{}(value={}{})".format(
self.__class__.__name__,
repr(value),
", tag={}".format(self.tag) if self.tag != self.__class__.tag else "",
f", tag={self.tag}" if self.tag != self.__class__.tag else "",
)


Expand Down Expand Up @@ -1725,7 +1725,7 @@ def __init__(self, requestName=None, tag=None):
def __repr__(self):
l = []
if self.tag != self.__class__.tag:
l.append("tag={}".format(self.tag))
l.append(f"tag={self.tag}")
return self.__class__.__name__ + "(" + ", ".join(l) + ")"


Expand Down Expand Up @@ -1763,7 +1763,7 @@ def __init__(
def __repr__(self):
l = []
if self.tag != self.__class__.tag:
l.append("tag={}".format(self.tag))
l.append(f"tag={self.tag}")
return self.__class__.__name__ + "(" + ", ".join(l) + ")"


Expand Down
Loading

0 comments on commit b5c302a

Please sign in to comment.