Skip to content

Commit

Permalink
Version 0.5.0 release (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Mar 13, 2024
1 parent 2fe2418 commit 381697b
Show file tree
Hide file tree
Showing 29 changed files with 1,285 additions and 1,288 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

Expand Down
17 changes: 8 additions & 9 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# .readthedocs.yml
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"
os: ubuntu-lts-latest
tools: {python: "3.11"}
jobs:
pre_create_environment:
- asdf plugin add poetry
- asdf install poetry latest
- asdf global poetry latest
- poetry config virtualenvs.create false
post_install:
- |
. "$(pwd | rev | sed 's/stuokcehc/svne/' | rev)/bin/activate"
&& poetry install --only main --only docs
- poetry self add poetry-plugin-export
- poetry export --only main --only docs --format=requirements.txt --output=requirements.txt

python:
install:
- requirements: requirements.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
fail_on_warning: true
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
We follow Semantic Versions.


## Version 0.5.0

### Features

- Drops `python3.7` and `python3.8` support
- Adds `python3.11` and `python3.12` support
- Removes `importlib_metadata` package

### Misc

- Updates multiple dependencies


## Version 0.4.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FROM python:3.10.7-alpine
LABEL maintainer="[email protected]"
LABEL vendor="wemake.services"

ENV DOTENV_LINTER_VERSION='0.4.0'
ENV DOTENV_LINTER_VERSION='0.5.0'
ENV REVIEWDOG_VERSION='v0.14.2'

RUN apk add --no-cache bash git wget
Expand Down
12 changes: 5 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
import os
import sys

import tomli

sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------

def _get_project_meta():
import tomlkit # noqa: WPS433

with open('../pyproject.toml') as pyproject:
file_contents = pyproject.read()

return tomlkit.parse(file_contents)['tool']['poetry']
with open('../pyproject.toml', mode='rb') as pyproject:
return tomli.load(pyproject)['tool']['poetry']


pkg_meta = _get_project_meta()
Expand All @@ -42,7 +40,7 @@ def _get_project_meta():

# -- General configuration ---------------------------------------------------

needs_sphinx = '3.3'
needs_sphinx = '5.3'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
Expand Down
12 changes: 8 additions & 4 deletions dotenv_linter/checker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import sys
from enum import IntEnum
from typing import Iterable, Iterator, NoReturn, Optional, Tuple

from typing_extensions import final
from typing import Any, Iterable, Iterator, NoReturn, Optional, Tuple, final

from dotenv_linter.exceptions import ParsingError
from dotenv_linter.grammar.fst import Module
Expand Down Expand Up @@ -96,7 +96,11 @@ class DotenvFileChecker(object):
"""

# TODO: create options
def __init__(self, filenames: Iterable[str], options=None) -> None:
def __init__(
self,
filenames: Iterable[str],
options: Any | None = None,
) -> None:
"""Creates new instance."""
self._fst_checker = _FSTChecker(filenames)

Expand Down
6 changes: 3 additions & 3 deletions dotenv_linter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
invoke_without_command=True,
)
@click.option('--version', is_flag=True, default=False)
def cli(version):
def cli(version: bool) -> None:
"""
Main entrypoint to the app.
Expand All @@ -30,14 +30,14 @@ def cli(version):
print(pkg_version) # noqa: WPS421


@cli.command()
@cli.command() # type: ignore[misc]
@click.argument(
'files',
nargs=-1,
required=True,
type=click.Path(exists=True, dir_okay=False),
)
def lint(files: Tuple[str, ...]):
def lint(files: Tuple[str, ...]) -> None:
"""Runs linting process for the given files."""
checker = DotenvFileChecker(files)

Expand Down
2 changes: 1 addition & 1 deletion dotenv_linter/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This module contains list of black-listed ``environment`` variables."""


from typing_extensions import Final
from typing import Final

#: List of variable we forbid to use.
NAMES_BLACKLIST: Final = frozenset((
Expand Down
2 changes: 1 addition & 1 deletion dotenv_linter/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing_extensions import final
from typing import final


@final
Expand Down
5 changes: 2 additions & 3 deletions dotenv_linter/grammar/fst.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
"""

from typing import Optional, Sequence, Type, TypeVar, Union
from typing import Optional, Sequence, Type, TypeVar, Union, final

from attr import dataclass, field
from ply import lex
from typing_extensions import final

from dotenv_linter.logics.text import normalize_text

Expand Down Expand Up @@ -119,4 +118,4 @@ def from_token(
class Module(Node):
"""Wrapper node that represents a single file with or without contents."""

body: Sequence[Union[Comment, Statement]]
body: Sequence[Union[Comment, Statement, Name]]
24 changes: 15 additions & 9 deletions dotenv_linter/grammar/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
"""

from typing import ClassVar, Tuple
from typing import Any, Callable, ClassVar, Tuple, TypeVar, final

from ply import lex
from typing_extensions import final
from typing_extensions import TypeAlias

from dotenv_linter.exceptions import ParsingError

_LexerState = Tuple[str, str]
_LexerState: TypeAlias = Tuple[str, str]

_CallableT = TypeVar('_CallableT', bound=Callable[..., Any])


def _token(re_string: str) -> Callable[[_CallableT], _CallableT]:
return lex.TOKEN(re_string) # type: ignore[no-any-return]


@final
Expand All @@ -35,7 +41,7 @@ class DotenvLexer(object):

re_whitespaces: ClassVar[str] = r'[ \t\v\f\u00A0]'

def __init__(self, **kwargs) -> None:
def __init__(self, **kwargs: Any) -> None:
"""Creates inner lexer."""
self._lexer = lex.lex(module=self, **kwargs)
self.reset()
Expand Down Expand Up @@ -70,30 +76,30 @@ def token(self) -> lex.LexToken:
"""
return self._lexer.token()

@lex.TOKEN(re_whitespaces + r'*[\w-]+')
@_token(re_whitespaces + r'*[\w-]+')
def t_NAME(self, token: lex.LexToken) -> lex.LexToken:
"""Parsing NAME tokens."""
token.lexer.push_state('name')
return token

@lex.TOKEN(re_whitespaces + r'*\#.*')
@_token(re_whitespaces + r'*\#.*')
def t_COMMENT(self, token: lex.LexToken) -> lex.LexToken:
"""Parsing COMMENT tokens."""
return token

@lex.TOKEN(re_whitespaces + '*=')
@_token(re_whitespaces + '*=')
def t_name_EQUAL(self, token: lex.LexToken) -> lex.LexToken:
"""Parsing EQUAL tokens."""
token.lexer.push_state('value')
return token

@lex.TOKEN('.+')
@_token('.+')
def t_value_VALUE(self, token: lex.LexToken) -> lex.LexToken:
"""Parsing VALUE tokens."""
token.lexer.pop_state()
return token

@lex.TOKEN(r'[\n\r\u2028\u2029]')
@_token(r'[\n\r\u2028\u2029]')
def t_ANY_newline(self, token: lex.LexToken) -> None:
"""
Defines a rule so we can track line numbers.
Expand Down
7 changes: 3 additions & 4 deletions dotenv_linter/grammar/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
"""

from typing import List, NoReturn, Optional, Union
from typing import Any, List, NoReturn, Optional, Union, final

from ply import lex, yacc
from typing_extensions import final

from dotenv_linter.exceptions import ParsingError
from dotenv_linter.grammar.fst import Assign, Comment, Module, Name, Statement
Expand All @@ -54,12 +53,12 @@ class DotenvParser(object):

tokens = DotenvLexer.tokens

def __init__(self, **kwarg) -> None:
def __init__(self, **kwarg: Any) -> None:
"""Creates inner parser instance."""
self._lexer = DotenvLexer()
self._parser = yacc.yacc(module=self, **kwarg) # should be last

def parse(self, to_parse: str, **kwargs) -> Module:
def parse(self, to_parse: str, **kwargs: Any) -> Module:
"""Parses input string to FST."""
self._body_items: List[Union[Comment, Statement]] = []
self._parser.parse(input=to_parse, lexer=self._lexer, **kwargs)
Expand Down
4 changes: 1 addition & 3 deletions dotenv_linter/logics/report.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
from itertools import chain
from typing import Iterable, List

from typing_extensions import final
from typing import Iterable, List, final

from dotenv_linter.violations.base import BaseViolation
from dotenv_linter.visitors.base import BaseVisitor
Expand Down
13 changes: 0 additions & 13 deletions dotenv_linter/types.py

This file was deleted.

26 changes: 10 additions & 16 deletions dotenv_linter/version.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import sys
import os
from importlib import metadata

# Note that we use ``sys.version_info`` directly,
# because that's how ``mypy`` knows about what we are doing.
if sys.version_info >= (3, 8): # pragma: no cover
from importlib import metadata as importlib_metadata # noqa: WPS433
else: # pragma: no cover
import importlib_metadata # noqa: WPS440, WPS433


def _get_version(distribution_name: str) -> str: # pragma: no cover
"""Fetches distribution version."""
return importlib_metadata.version(distribution_name) # type: ignore


pkg_name = 'dotenv-linter'
#: Package name:
pkg_name = os.path.basename(os.path.dirname(__file__))

#: We store the version number inside the `pyproject.toml`:
pkg_version = _get_version(pkg_name)
try:
pkg_version = metadata.version(pkg_name)
except metadata.PackageNotFoundError:
# This mainly happens in RTD env, where we set the metadata
# from `pyproject.toml` file:
pkg_version = ''
2 changes: 1 addition & 1 deletion dotenv_linter/violations/assigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from typing_extensions import final
from typing import final

from dotenv_linter.violations.base import BaseFSTViolation

Expand Down
Loading

0 comments on commit 381697b

Please sign in to comment.