What I learned by writing a Python Pull Request for the first time in my life

I haven't touched Python at all, but I happened to upgrade and brush up Kafka extensions for Azure Functions, so I need to update the Python library as part of that. occured.

I had a hard time because I didn't know the language specifications and tools so much, so I want to record what I learned.

Virtual Environment Since Python 3.4, a mechanism called Virtual Environment is installed as standard. This will separate the environment when you install the library. There is something close to the mechanism of managing the library of npm in node or bundle in Ruby.

Specifically, execute the following command.

$ python -m venv .venv

This will create a directory called .venv. Execute the following command to enable venv.

$ source .venv/bin/activate

This will allow future installations of libraries to be saved under .venv so that python programs can reference the libraries installed under them while .venv is activated. Will be.

setup.py If you want to add a library, add an entry to setup.py. [Repository] I contributed (https://github.com/Azure/azure-functions-python-library/blob/dev/setup.py)

$ python -m pip install -U -e ./[dev\]

This command will also install the dev part of ʻextras_require in setup.py. Note that -U means ʻUpgrade, which updates the package to a newer version. -e means ʻEditable, which makes the installed library editable. It is usually not in an editable format. When debugging a library, you'll want to experiment and see the source, so it's a good idea to add -e`.

setup.py

from setuptools import setup
from azure.functions import __version__


setup(
    name='azure-functions',
    version=__version__,
    description='Azure Functions for Python',
    long_description='Python support for Azure Functions is based on '
                     'Python3.[6|7|8], serverless hosting on Linux and the '
                     'Functions 2.0 and 3.0 runtime. This module provides the '
                     'rich binding definitions for Azure Functions for Python '
                     'apps.',
    author='Microsoft Corporation',
    author_email='[email protected]',
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Intended Audience :: Developers',
        'Programming Language :: Python :: 3',
        'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Operating System :: MacOS :: MacOS X',
        'Environment :: Web Environment',
        'Development Status :: 5 - Production/Stable',
    ],
    license='MIT',
    packages=['azure.functions'],
    package_data={
        'azure.functions': ['py.typed']
    },
    extras_require={
        'dev': [
            'flake8~=3.7.9',
            'mypy',
            'pytest',
            'requests==2.*',
            'coverage'
        ]
    },
    include_package_data=True,
    test_suite='tests'
)

Lint

I haven't tried it yet, but Python's Lint is quite quirky, so it's a good idea to include Linter.

PR Python PR for the first time in my life

Recommended Posts

What I learned by writing a Python Pull Request for the first time in my life
What I got into Python for the first time
MongoDB for the first time in Python
I tried python programming for the first time.
A useful note when using Python for the first time in a while
I tried Python on Mac for the first time.
Register a task in cron for the first time
I tried python on heroku for the first time
For the first time, I learned about Unix (Linux).
What I learned by participating in the ISUCON10 qualifying
What I learned in Python
See python for the first time
What I have learned in the past year as an elderly person (unsuitable for my age)
I tried tensorflow for the first time
For the first time in Numpy, I will update it from time to time
I tried Mind Meld for the first time
What I learned by implementing how to create a Default Box for SSD
I searched for the skills needed to become a web engineer in Python
[Example of Python improvement] I learned the basics of Python on a free site in 2 weeks.
After attending school, I participated in SIGNATE's BEGINNER limited competition for the first time.
The concept of reference in Python collapsed for a moment, so I experimented a little.
I want to create a lunch database [EP1] Django study for the first time
I want to create a lunch database [EP1-4] Django study for the first time
AI Gaming I tried it for the first time
What does the last () in a function mean in Python?
I made a class to get the analysis result by MeCab in ndarray with python
What is a dog? Django--Getting Started with Form for the First Time POST Transmission Volume
What kind of environment should people who are learning Python for the first time build?
What I learned by solving 30 questions of python Project Euler
[Understand in the shortest time] Python basics for data analysis
I tried the Google Cloud Vision API for the first time
What beginners learned from the basics of variables in python
I want to create a Dockerfile for the time being.
Kaggle for the first time (kaggle ①)
Kaguru for the first time
Put the process to sleep for a certain period of time (seconds) or more in Python
The story of releasing a Python text check tool on GitHub x CircleCI for the first time
I made a function to check if the webhook is received in Lambda for the time being
The story of returning to the front line for the first time in 5 years and refactoring Python Django
I compared the calculation time of the moving average written in Python
Differences C # engineers felt when learning python for the first time
Python> I made a test code for my own external file
Read the standard output of a subprocess line by line in Python
[Introduction to Python] How to use the in operator in a for statement?
A function that measures the processing time of a method in python
The first time a programming beginner tried simple data analysis by programming
I made a scaffolding tool for the Python web framework Bottle
Play by hitting the Riot Games API in Python First half
Try using FireBase Cloud Firestore in Python for the time being
[For self-learning] Go2 for the first time
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
I learned about processes in Python
I wrote the queue in Python
What is the python underscore (_) for?
What I learned in two months before the product was released as a machine learning fucking amateur
Start Django for the first time
The first step in Python Matplotlib
When writing a program in Python
I wrote the stack in Python
I tried logistic regression analysis for the first time using Titanic data
A memo organized by renaming the file names in the folder with python