Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 408f962

Browse files
authored
Drop support for Python 3.5 (#510)
* Drop support for Python 3.5 * Upgrade Python syntax with pyupgrade --py36-plus * Drop support for Python 3.5 * Remove D302, redundant now Python 2 is dropped
1 parent 17a1c64 commit 408f962

18 files changed

+36
-84
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [macos-latest, ubuntu-latest, windows-latest]
11-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9-dev]
11+
python-version: [3.6, 3.7, 3.8, 3.9-dev]
1212

1313
steps:
1414
- uses: actions/checkout@v2

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ docstring conventions.
2222
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
2323
should not be considered a reference implementation.
2424

25-
**pydocstyle** supports Python 3.5, 3.6, 3.7 and 3.8.
25+
**pydocstyle** supports Python 3.6, 3.7 and 3.8.
2626

2727

2828
Quick Start

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# pydocstyle documentation build configuration file, created by
42
# sphinx-quickstart on Fri Jan 30 20:30:42 2015.
53
#

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ docstring conventions.
88
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
99
should not be considered a reference implementation.
1010

11-
**pydocstyle** supports Python 3.5, 3.6, 3.7 and 3.8.
11+
**pydocstyle** supports Python 3.6, 3.7 and 3.8.
1212

1313

1414
.. include:: quickstart.rst

docs/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Release Notes
88
Current Development Version
99
---------------------------
1010

11+
Major Updates
12+
13+
* Support for Python 3.5 has been dropped (#510).
14+
1115
New Features
1216

1317
* Add flag to disable `# noqa` comment processing in API (#485).

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from setuptools import setup
2-
import sys
32

43
# Do not update the version manually - it is managed by `bumpversion`.
54
version = '5.1.2rc'
@@ -24,14 +23,14 @@
2423
'Environment :: Console',
2524
'Development Status :: 5 - Production/Stable',
2625
'Programming Language :: Python :: 3',
27-
'Programming Language :: Python :: 3.5',
2826
'Programming Language :: Python :: 3.6',
2927
'Programming Language :: Python :: 3.7',
3028
'Programming Language :: Python :: 3.8',
29+
'Programming Language :: Python :: 3 :: Only',
3130
'Operating System :: OS Independent',
3231
'License :: OSI Approved :: MIT License',
3332
],
34-
python_requires='>=3.5',
33+
python_requires='>=3.6',
3534
keywords='pydocstyle, PEP 257, pep257, PEP 8, pep8, docstrings',
3635
packages=('pydocstyle',),
3736
package_dir={'': 'src'},
@@ -43,6 +42,6 @@
4342
],
4443
},
4544
project_urls={
46-
'Release Notes': 'http://www.pydocstyle.org/en/latest/release_notes.html',
45+
'Release Notes': 'https://www.pydocstyle.org/en/latest/release_notes.html',
4746
},
4847
)

src/pydocstyle/checker.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -385,23 +385,6 @@ def check_backslashes(self, definition, docstring):
385385
and not docstring.startswith(('r', 'ur'))):
386386
return violations.D301()
387387

388-
@check_for(Definition)
389-
def check_unicode_docstring(self, definition, docstring):
390-
r'''D302: Use u""" for docstrings with Unicode.
391-
392-
For Unicode docstrings, use u"""Unicode triple-quoted strings""".
393-
394-
'''
395-
if 'unicode_literals' in definition.module.future_imports:
396-
return
397-
398-
# Just check that docstring is unicode, check_triple_double_quotes
399-
# ensures the correct quotes.
400-
if docstring and sys.version_info[0] <= 2:
401-
if not is_ascii(docstring) and not docstring.startswith(
402-
('u', 'ur')):
403-
return violations.D302()
404-
405388
@staticmethod
406389
def _check_ends_with(docstring, chars, violation):
407390
"""First line ends with one of `chars`.
@@ -453,13 +436,7 @@ def check_imperative_mood(self, function, docstring): # def context
453436
if check_word in IMPERATIVE_BLACKLIST:
454437
return violations.D401b(first_word)
455438

456-
try:
457-
correct_forms = IMPERATIVE_VERBS.get(stem(check_word))
458-
except UnicodeDecodeError:
459-
# This is raised when the docstring contains unicode
460-
# characters in the first word, but is not a unicode
461-
# string. In which case D302 will be reported. Ignoring.
462-
return
439+
correct_forms = IMPERATIVE_VERBS.get(stem(check_word))
463440

464441
if correct_forms and check_word not in correct_forms:
465442
best = max(
@@ -985,7 +962,7 @@ def check(filenames, select=None, ignore=None, ignore_decorators=None, ignore_in
985962
code = getattr(error, 'code', None)
986963
if code in checked_codes:
987964
yield error
988-
except (EnvironmentError, AllError, ParseError) as error:
965+
except (OSError, AllError, ParseError) as error:
989966
log.warning('Error in file %s: %s', filename, error)
990967
yield error
991968
except tk.TokenError:

src/pydocstyle/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _read_configuration_file(self, path):
316316
continue
317317

318318
if opt.replace('_', '-') not in self.CONFIG_FILE_OPTIONS:
319-
log.warning("Unknown option '{}' ignored".format(opt))
319+
log.warning(f"Unknown option '{opt}' ignored")
320320
continue
321321

322322
normalized_opt = opt.replace('-', '_')
@@ -335,7 +335,7 @@ def _read_configuration_file(self, path):
335335

336336
if options is not None:
337337
if not self._validate_options(options):
338-
raise IllegalConfiguration('in file: {}'.format(path))
338+
raise IllegalConfiguration(f'in file: {path}')
339339

340340
return options, should_inherit
341341

@@ -388,7 +388,7 @@ def _create_check_config(cls, options, use_defaults=True):
388388

389389
kwargs = dict(checked_codes=checked_codes)
390390
for key in ('match', 'match_dir', 'ignore_decorators'):
391-
kwargs[key] = getattr(cls, 'DEFAULT_{}_RE'.format(key.upper())) \
391+
kwargs[key] = getattr(cls, f'DEFAULT_{key.upper()}_RE') \
392392
if getattr(options, key) is None and use_defaults \
393393
else getattr(options, key)
394394
return CheckConfiguration(**kwargs)
@@ -521,7 +521,7 @@ def _get_set(value_str):
521521
522522
"""
523523
return cls._expand_error_codes(
524-
set([x.strip() for x in value_str.split(",")]) - {""}
524+
{x.strip() for x in value_str.split(",")} - {""}
525525
)
526526

527527
for opt in optional_set_options:

src/pydocstyle/parser.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __eq__(self, other):
5555
def __repr__(self):
5656
kwargs = ', '.join('{}={!r}'.format(field, getattr(self, field))
5757
for field in self._fields)
58-
return '{}({})'.format(self.__class__.__name__, kwargs)
58+
return f'{self.__class__.__name__}({kwargs})'
5959

6060

6161
class Definition(Value):
@@ -97,9 +97,9 @@ def is_empty_or_comment(line):
9797
return ''.join(reversed(list(filtered_src)))
9898

9999
def __str__(self):
100-
out = 'in {} {} `{}`'.format(self._publicity, self._human, self.name)
100+
out = f'in {self._publicity} {self._human} `{self.name}`'
101101
if self.skipped_error_codes:
102-
out += ' (skipping {})'.format(self.skipped_error_codes)
102+
out += f' (skipping {self.skipped_error_codes})'
103103
return out
104104

105105

@@ -211,7 +211,7 @@ def is_public(self):
211211
# Check if we are a setter/deleter method, and mark as private if so.
212212
for decorator in self.decorators:
213213
# Given 'foo', match 'foo.bar' but not 'foobar' or 'sfoo'
214-
if re(r"^{}\.".format(self.name)).match(decorator.name):
214+
if re(fr"^{self.name}\.").match(decorator.name):
215215
return False
216216
name_is_public = (not self.name.startswith('_') or
217217
self.name in VARIADIC_MAGIC_METHODS or
@@ -343,7 +343,7 @@ def __init__(self, *args):
343343
self.kind = TokenKind(self.kind)
344344

345345
def __str__(self):
346-
return "{!r} ({})".format(self.kind, self.value)
346+
return f"{self.kind!r} ({self.value})"
347347

348348

349349
class Parser:
@@ -472,8 +472,7 @@ def parse_definitions(self, class_, dunder_all=False):
472472
yield self.parse_definition(class_._nest(self.current.value))
473473
elif self.current.kind == tk.INDENT:
474474
self.consume(tk.INDENT)
475-
for definition in self.parse_definitions(class_):
476-
yield definition
475+
yield from self.parse_definitions(class_)
477476
elif self.current.kind == tk.DEDENT:
478477
self.consume(tk.DEDENT)
479478
return

src/pydocstyle/violations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def set_context(self, definition: Definition, explanation: str) -> None:
5252
@property
5353
def message(self) -> str:
5454
"""Return the message to print to the user."""
55-
ret = '{}: {}'.format(self.code, self.short_desc)
55+
ret = f'{self.code}: {self.short_desc}'
5656
if self.context is not None:
5757
specific_error_msg = self.context.format(*self.parameters)
58-
ret += ' ({})'.format(specific_error_msg)
58+
ret += f' ({specific_error_msg})'
5959
return ret
6060

6161
@property
@@ -69,7 +69,7 @@ def lines(self) -> str:
6969
lines_stripped = list(reversed(list(dropwhile(is_blank,
7070
reversed(lines)))))
7171
numbers_width = len(str(offset + len(lines_stripped)))
72-
line_format = '{{:{}}}:{{}}'.format(numbers_width)
72+
line_format = f'{{:{numbers_width}}}:{{}}'
7373
for n, line in enumerate(lines_stripped):
7474
if line:
7575
line = ' ' + line
@@ -159,7 +159,7 @@ def to_rst(cls) -> str:
159159
for group in cls.groups:
160160
table += sep_line
161161
table += blank_line
162-
table += '|' + '**{}**'.format(group.name).center(max_len + 9) + '|\n'
162+
table += '|' + f'**{group.name}**'.center(max_len + 9) + '|\n'
163163
table += blank_line
164164
for error in group.errors:
165165
table += sep_line
@@ -214,7 +214,7 @@ def to_rst(cls) -> str:
214214
D300 = D3xx.create_error('D300', 'Use """triple double quotes"""',
215215
'found {0}-quotes')
216216
D301 = D3xx.create_error('D301', 'Use r""" if any backslashes in a docstring')
217-
D302 = D3xx.create_error('D302', 'Use u""" for Unicode docstrings')
217+
D302 = D3xx.create_error('D302', 'Deprecated: Use u""" for Unicode docstrings')
218218

219219
D4xx = ErrorRegistry.create_group('D4', 'Docstring Content Issues')
220220
D400 = D4xx.create_error('D400', 'First line should end with a period',

0 commit comments

Comments
 (0)