Skip to content

Commit

Permalink
Merge pull request #70 from deronnax/pyupgrade
Browse files Browse the repository at this point in the history
remove python2 leftovers
  • Loading branch information
yeisonvargasf authored Oct 10, 2023
2 parents eb917b3 + 69de983 commit 93f4bbb
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 37 deletions.
2 changes: 0 additions & 2 deletions dparse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
"""Top-level package for Dependency Parser."""

__author__ = """Jannis Gebauer"""
Expand Down
7 changes: 2 additions & 5 deletions dparse/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

import json
from json import JSONEncoder

from . import filetypes, errors


class Dependency(object):
class Dependency:
"""
"""
Expand Down Expand Up @@ -102,7 +99,7 @@ def default(self, o):
return JSONEncoder.default(self, o)


class DependencyFile(object):
class DependencyFile:
"""
"""
Expand Down
4 changes: 0 additions & 4 deletions dparse/errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import


class UnknownDependencyFileError(Exception):
"""
Expand Down
3 changes: 0 additions & 3 deletions dparse/filetypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

requirements_txt = "requirements.txt"
conda_yml = "conda.yml"
setup_cfg = "setup.cfg"
Expand Down
12 changes: 4 additions & 8 deletions dparse/parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

import os
from collections import OrderedDict
import re
Expand Down Expand Up @@ -80,7 +77,7 @@ def yield_lines(strs):
yield PackagingRequirement(line)


class RequirementsTXTLineParser(object):
class RequirementsTXTLineParser:
"""
"""
Expand Down Expand Up @@ -112,7 +109,7 @@ def parse(cls, line):
return dep


class Parser(object):
class Parser:
"""
"""
Expand All @@ -132,8 +129,7 @@ def iter_lines(self, lineno=0):
:param lineno:
:return:
"""
for line in self.lines[lineno:]:
yield line
yield from self.lines[lineno:]

@property
def lines(self):
Expand Down Expand Up @@ -241,7 +237,7 @@ def parse(self):
req_file_path = self.resolve_file(self.obj.path, line)

if self.resolve and os.path.exists(req_file_path):
with open(req_file_path, 'r') as f:
with open(req_file_path) as f:
content = f.read()

dep_file = DependencyFile(
Expand Down
3 changes: 0 additions & 3 deletions dparse/regex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

HASH_REGEX = r"--hash[=| ]\w+:\w+"
8 changes: 3 additions & 5 deletions dparse/updater.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import re
import json
import tempfile
Expand All @@ -12,7 +10,7 @@
import tomli as tomllib


class RequirementsTXTUpdater(object):
class RequirementsTXTUpdater:
SUB_REGEX = r"^{}(?=\s*\r?\n?$)"

@classmethod
Expand Down Expand Up @@ -81,7 +79,7 @@ class SetupCFGUpdater(CondaYMLUpdater):
pass


class PipfileUpdater(object):
class PipfileUpdater:
@classmethod
def update(cls, content, dependency, version, spec="==", hashes=()):
data = tomllib.loads(content)
Expand All @@ -107,7 +105,7 @@ def update(cls, content, dependency, version, spec="==", hashes=()):
return data


class PipfileLockUpdater(object):
class PipfileLockUpdater:
@classmethod
def update(cls, content, dependency, version, spec="==", hashes=()):
data = json.loads(content)
Expand Down
2 changes: 0 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

"""Unit test package for dparse."""
2 changes: 0 additions & 2 deletions tests/test_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
"""Tests for `dparse.dependencies`"""

import pytest
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import sys
from pathlib import PurePath
Expand Down
1 change: 0 additions & 1 deletion tests/test_updater.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Tests for `dparse.updater`"""

Expand Down

0 comments on commit 93f4bbb

Please sign in to comment.