Skip to content

Commit

Permalink
Moved code into src dir (#1)
Browse files Browse the repository at this point in the history
* Renamed linter class

* Moved sources under src

* Updated version
  • Loading branch information
expobrain committed Sep 10, 2020
1 parent a15d43f commit 7352808
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fmt:
--remove-all-unused-imports \
--ignore-init-module-imports \
-r \
setup.py tests flake8_datetime_utcnow
setup.py tests src
isort --profile black .
black .

Expand All @@ -17,6 +17,6 @@ check:
--ignore-init-module-imports \
-r \
-c \
setup.py tests flake8_datetime_utcnow
setup.py tests src
isort --profile black -c .
black --check .
1 change: 0 additions & 1 deletion flake8_datetime_utcnow/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion flake8_datetime_utcnow/__version__.py

This file was deleted.

9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path

from setuptools import setup
from setuptools import find_namespace_packages, setup

version = (
(Path(__file__).parent / "flake8_datetime_utcnow" / "__version__.py")
(Path(__file__).parent / "src" / "flake8_datetime_utcnow" / "__version__.py")
.read_text()
.split("=")[1]
.strip()[1:-1]
Expand All @@ -17,11 +17,12 @@
author="Daniele Esposti",
author_email="daniele.esposti@gmail.com",
url="https://github.com/expobrain/flake8-datetime-utcnow-plugin",
packages=["flake8_datetime_utcnow"],
packages=find_namespace_packages(where="src"),
package_dir={"": "src"},
install_requires=["flake8>=3.0.0"],
entry_points={
"flake8.extension": [
"U1 = flake8_datetime_utcnow:DatetimeUtcnowPlugin",
"U1 = flake8_datetime_utcnow:DatetimeUtcnowLinter",
],
},
classifiers=[
Expand Down
1 change: 1 addition & 0 deletions src/flake8_datetime_utcnow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from flake8_datetime_utcnow.linter import DatetimeUtcnowLinter
1 change: 1 addition & 0 deletions src/flake8_datetime_utcnow/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0beta3"
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@


def error(lineno: int, offset: int, code: str, message: str):
return (1, 10, f"{code} {message}", DatetimeUtcnowPlugin)
return (1, 10, f"{code} {message}", DatetimeUtcnowLinter)


class DatetimeUtcnowPlugin:
class DatetimeUtcnowLinter:
name = "flake8_datetime_utcnow_plugin"
version = __version__

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pathlib import Path
import os
import sys

sys.path.append((Path(__file__).parent / ".." / "src").as_posix())
6 changes: 3 additions & 3 deletions tests/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from flake8_datetime_utcnow.linter import DatetimeUtcnowPlugin
from flake8_datetime_utcnow.linter import DatetimeUtcnowLinter


@pytest.mark.parametrize(
Expand All @@ -15,7 +15,7 @@
)
def test_linter_positive(code: str):
tree = ast.parse(code)
checker = DatetimeUtcnowPlugin(tree)
checker = DatetimeUtcnowLinter(tree)

for lineno, col_offset, msg, instance in checker.run():
assert msg.startswith("U100 Avoid using utcnow()")
Expand All @@ -24,6 +24,6 @@ def test_linter_positive(code: str):
@pytest.mark.parametrize("code", ["random_symbol.utcnow()"])
def test_linter_negative(code: str):
tree = ast.parse(code)
checker = DatetimeUtcnowPlugin(tree)
checker = DatetimeUtcnowLinter(tree)

assert len(list(checker.run())) == 0

0 comments on commit 7352808

Please sign in to comment.