Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worflows, Badges, and Black #177

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
92 changes: 92 additions & 0 deletions .github/workflows/pydle-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ "develop", "master" ]
pull_request:
branches: [ "develop", "master" ]
schedule:
- cron: '25 10 * * 3'

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ __pycache__
/.tox
/*.egg-info

.idea/
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ pydle
=====
Python IRC library.
-------------------
![PyPI](https://img.shields.io/pypi/v/pydle)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydle)
![PyPI - License](https://img.shields.io/pypi/l/pydle)
![Read the Docs](https://img.shields.io/readthedocs/pydle)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Downloads](https://pepy.tech/badge/pylint)](https://pepy.tech/project/pylint)

pydle is a compact, flexible and standards-abiding IRC library for Python 3.5 through 3.9.

Expand Down
61 changes: 30 additions & 31 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,92 @@
### -- General options -- ###

# Make autodoc and import work.
if path.exists(path.join('..', 'pydle')):
sys.path.insert(0, os.path.abspath('..'))
if path.exists(path.join("..", "pydle")):
sys.path.insert(0, os.path.abspath(".."))
import pydle

# General information about the project.
project = pydle.__name__
copyright = '2013-{current}, Shiz'.format(current=datetime.date.today().year)
copyright = "2013-{current}, Shiz".format(current=datetime.date.today().year)
version = release = pydle.__version__

# Sphinx extensions to use.
extensions = [
# Generate API description from code.
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
# Generate unit tests from docstrings.
'sphinx.ext.doctest',
"sphinx.ext.doctest",
# Link to Sphinx documentation for related projects.
'sphinx.ext.intersphinx',
"sphinx.ext.intersphinx",
# Generate TODO descriptions from docstrings.
'sphinx.ext.todo',
"sphinx.ext.todo",
# Conditional operator for documentation.
'sphinx.ext.ifconfig',
"sphinx.ext.ifconfig",
# Include full source code with documentation.
'sphinx.ext.viewcode'
"sphinx.ext.viewcode",
]

# Documentation links for projects we link to.
intersphinx_mapping = {
'python': ('http://docs.python.org/3', None)
}
intersphinx_mapping = {"python": ("http://docs.python.org/3", None)}


### -- Build locations -- ###

templates_path = ['_templates']
exclude_patterns = ['_build']
source_suffix = '.rst'
master_doc = 'index'
templates_path = ["_templates"]
exclude_patterns = ["_build"]
source_suffix = ".rst"
master_doc = "index"


### -- General build settings -- ###

pygments_style = 'trac'
pygments_style = "trac"


### -- HTML output -- ##

# Only set RTD theme if we're building locally.
if os.environ.get('READTHEDOCS', None) != 'True':
if os.environ.get("READTHEDOCS", None) != "True":
import sphinx_rtd_theme

html_theme = "sphinx_rtd_theme"
html_theme_path = [ sphinx_rtd_theme.get_html_theme_path() ]
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_show_sphinx = False
htmlhelp_basename = 'pydledoc'
htmlhelp_basename = "pydledoc"


### -- LaTeX output -- ##

latex_documents = [
('index', 'pydle.tex', 'pydle Documentation', 'Shiz', 'manual'),
("index", "pydle.tex", "pydle Documentation", "Shiz", "manual"),
]


### -- Manpage output -- ###

man_pages = [
('index', 'pydle', 'pydle Documentation', ['Shiz'], 1)
]
man_pages = [("index", "pydle", "pydle Documentation", ["Shiz"], 1)]


### -- Sphinx customization code -- ##


def skip(app, what, name, obj, skip, options):
if skip:
return True
if name.startswith('_') and name != '__init__':
if name.startswith("_") and name != "__init__":
return True
if name.startswith('on_data'):
if name.startswith("on_data"):
return True
if name.startswith('on_raw_'):
if name.startswith("on_raw_"):
return True
if name.startswith('on_ctcp') and name not in ('on_ctcp', 'on_ctcp_reply'):
if name.startswith("on_ctcp") and name not in ("on_ctcp", "on_ctcp_reply"):
return True
if name.startswith('on_isupport_'):
if name.startswith("on_isupport_"):
return True
if name.startswith('on_capability_'):
if name.startswith("on_capability_"):
return True
return False


def setup(app):
app.connect('autodoc-skip-member', skip)
app.connect("autodoc-skip-member", skip)
26 changes: 16 additions & 10 deletions pydle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
from functools import cmp_to_key
from . import connection, protocol, client, features
from .client import Error, NotInChannel, AlreadyInChannel, BasicClient, ClientPool
from .features.ircv3.cap import NEGOTIATING as CAPABILITY_NEGOTIATING, FAILED as CAPABILITY_FAILED, \
NEGOTIATED as CAPABILITY_NEGOTIATED
from .features.ircv3.cap import (
NEGOTIATING as CAPABILITY_NEGOTIATING,
FAILED as CAPABILITY_FAILED,
NEGOTIATED as CAPABILITY_NEGOTIATED,
)


__name__ = 'pydle'
__version__ = '0.9.4rc1'
__name__ = "pydle"
__version__ = "0.9.4rc1"
__version_info__ = (0, 9, 4)
__license__ = 'BSD'
__license__ = "BSD"


def featurize(*features):
""" Put features into proper MRO order. """
"""Put features into proper MRO order."""

def compare_subclass(left, right):
if issubclass(left, right):
Expand All @@ -24,16 +27,19 @@ def compare_subclass(left, right):
return 0

sorted_features = sorted(features, key=cmp_to_key(compare_subclass))
name = 'FeaturizedClient[{features}]'.format(
features=', '.join(feature.__name__ for feature in sorted_features))
name = "FeaturizedClient[{features}]".format(
features=", ".join(feature.__name__ for feature in sorted_features)
)
return type(name, tuple(sorted_features), {})


class Client(featurize(*features.ALL)):
""" A fully featured IRC client. """
"""A fully featured IRC client."""

...


class MinimalClient(featurize(*features.LITE)):
""" A cut-down, less-featured IRC client. """
"""A cut-down, less-featured IRC client."""

...
Loading