pre-commit: run flake8 with python 3.6.8 - python-3.6

I installed Pyton 3.6.8 on my system.
python3 --version //-> Python 3.6.8
python3.6 --version //-> Python 3.6.8
My pre-commit-config.yaml is:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
language_version: python3.6
I installed the pre-commit hook for my project.
Every time when I want to commit some changes to git, the pre-commit is running with the flake8 error:
TYP005 NamedTuple does not support defaults in 3.6.0
This is true for Python 3.6.0, because this feature is introduced and allowed with Python 3.6.1+.
https://docs.python.org/3.6/library/typing.html#typing.NamedTuple
How can I configure flake8 to run with Python 3.6.8?
EDIT
When I run flake8 file.rb, I don`t get the error message TYP005.
python3 -m pip install flake
flake --version //-> 3.7.9 (the same version as in the pre-commit script file)

disclaimer: I'm the author of two of the tools in question (pre-commit, flake8-typing-imports) and the maintainer of the other (flake8)
the TYP005 code comes from flake8-typing-imports
there are two options for indicating your minimum supported version to flake8-typing-imports, the first is a command line argument / flake8 setting:
--min-python-version 3.6.1
or in your flake8 configuration
[flake8]
min_python_version = 3.6.1
if you're distributing a library, you can indicate the minimum supported version using the python_requires metadata -- this is specified in setup.cfg
[options]
python_requires >= 3.6.1
an aside, I believe there's some information missing from your question, without additional_dependencies in your pre-commit configuration, flake8 will be installed in isolation and won't have access to plugins such as flake8-typing-imports -- my guess is you've actually got a configuration similar to:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports==1.9.0]
when speaking of command line arguments above, you could specify them as args here (though I personally prefer the configuration file approaches)
- id: flake8
args: [--min-python-version, '3.6.1']
additional_dependencies: [flake8-typing-imports==1.9.0]

Related

Incompatible qt versions with qbs

I work on a github action. I need to compile a programm against a specific qt version. The program is build with qbs. I have a problem to configure qbs such that it uses the correct Qt version. There are two versions installed. The first one is installed with sudo apt-get. It is the version 5.12.8. This version is installed as a dependency of qbs. The second qt is installed with aqt. It is the version 5.15.2.
The github action script is
name: Qbs-Tests
on: push
jobs:
ubuntu:
name: "test on ubuntu"
runs-on: ubuntu-latest
steps:
- name: install clang12, qbs, qmake
run: |
sudo apt-get update -y
sudo apt-get install -y clang-12 llvm-12 qbs qt5-qmake
- name: Install Qt
uses: jurplel/install-qt-action#v2
with:
version: 5.15.2
- name: setup qbs
run: |
qbs setup-qt $Qt5_DIR/bin/qmake qt
qbs config --list profiles
qbs config defaultProfile qt
But this ist not possible, since I received the error message
Creating profile 'qt'.
You may want to set up toolchain information for the generated Qt profile.
profiles.qt.moduleProviders.Qt.qmakeFilePaths: "/home/runner/work/QSqlMigrator/Qt/5.15.2/gcc_64/bin/qmake"
Cannot mix incompatible Qt library (5.12.8) with this library (5.15.2)
I also tried to ignore the system search path (Only the last line is exchanged). See qbs Doc
qbs config profiles.qt.preferences.ignoreSystemSearchPaths true
But this leads also to the error message
Cannot mix incompatible Qt library (5.12.8) with this library (5.15.2)
Why I am unable to configure the profile? I am even unable to ignore the system path. Where came the libary incompatibility from? I only configure 5.15.2.

The repository is not signed to install a package on Ubuntu

I'm using Salt (SaltStack) to install packages in Ubuntu 18.04. I want to install a formula for docker, for example. When I apply docker state, I get an error that a package can't be installed, because the package repository that is used in a formula isn't signed.
ID: docker package
Function: pkg.installed
Name: docker-engine
Result: False
Comment: An error was encountered while installing package(s): E: Failed to fetch https://apt.dockerproject.org/repo/dists/ubuntu-bionic/InRelease 403 Forbidden [IP: 13.33.98.216 443]
E: The repository 'https://apt.dockerproject.org/repo ubuntu-bionic InRelease' is not signed.
Same happens when I'm using another formula.
I found out that if I would install a package manually through a command-line, I would use a --allow-unauthenticated option.
But what is the way to solve this issue while using Salt and salt-formulas? How can I install a package from a not signed repository?
Disabling package verification is a very bad idea in any scenario. The Docker repository is perfectly compliant with Ubuntu package signing standards and publishes a GPG key to verify them. It can be added to the system manually:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
But this is not the primary problem here - it's that the Salt rule you're referring to is outdated and sets an incorrect Docker repo URL - in recent installation script they've changed it from https://apt.dockerproject.org/repo to https://download.docker.com/linux/ubuntu/ and while the old mirror seems to be working, the signature files for new releases don't seem to be available there, which confuses apt.
So using Ansible (sorry, I don't know Salt):
- apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
- apt_repository:
repo: 'deb https://download.docker.com/linux/ubuntu/ bionic stable'
- apt: name=docker-ce
You can use skip_verify to avoid GPG verification check (e.g., --allow-unauthenticated, or --force-bad-verify),
httpd:
pkg.installed:
- fromrepo: mycustomrepo
- skip_verify: True

rpmbuild install dependency

I'm new to rpmbuild + spec files and I tried the following tutorial to build the "hello world" example.
Manage to get it working, but I wanted to learn how dependencies/requires works. Therefore, I tried to duplicate another "hello world 2" example and link it as a dependency to the first in the spec file below.
However I keep getting the error below. Is there a way that yum install will pick up the helloworld1 and install automatically when i yum install helloworld2 ?
Any example for me learn from?
SPEC FILE
Name: helloworld2
Version: 2.0
Release: 1%{?dist}
Summary: A hello world program
License: GPLv3+
URL: https://blog.packagecloud.io
Source0: helloworld2-2.0.tar.gz
#BuildRequires: helloworld1
Requires(preun): helloworld1
#PreReq: testYW
%description
A helloworld program from the packagecloud.io blog!
%prep
%setup
%build
make PREFIX=/usr %{?_smp_mflags}
%install
make PREFIX=/usr DESTDIR=%{?buildroot} install
echo %{?buildroot}
%clean
rm -rf %{buildroot}
%files
%{_bindir}/helloworld2
ERORR
COMMAND >> yum install RPMS/x86_64/helloworld2-2.0-1.el6.x86_64.rpm
Loaded plugins: product-id, search-disabled-repos, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Examining RPMS/x86_64/helloworld2-2.0-1.el6.x86_64.rpm: helloworld2-2.0-1.el6.x86_64
Marking RPMS/x86_64/helloworld2-2.0-1.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package helloworld2.x86_64 0:2.0-1.el6 will be installed
--> Processing Dependency: helloworld1 for package: helloworld2-2.0-1.el6.x86_64
--> Finished Dependency Resolution
Error: Package: helloworld2-2.0-1.el6.x86_64 (/helloworld2-2.0-1.el6.x86_64)
Requires: helloworld1
You could try using --skip-broken to work around the problem
since helloworld2 requires helloworld1; you should either install helloworld1 first; either install both together. Since helloworld2 depends on helloworld1; you cannot install him without installing helloworld1 first (or at the same time).
okay ! i got the answer !
i can either do a yum install *.rpm , which it will do its own dependency
else putting all the new rpm file into the repository and it will pick it up :)

Travis CI Build Failing

I am having an issue with Travis CI - the commits that I push all fail with the same error:
0.06s$ curl -sSL "http://llvm.org/apt/llvm-snapshot.gpg.key" | sudo -E apt-key add -
gpg: no valid OpenPGP data found.
The command "curl -sSL "http://llvm.org/apt/llvm-snapshot.gpg.key" | sudo -E apt-key add -" failed and exited with 2 during .
Your build has been stopped.
I tried to rebuild a previous commit that built successfully and the same error occurs. Any suggestions as to how to troubleshoot the issue?
http://llvm.org/apt/llvm-snapshot.gpg.key is returning 404 since about 2 days ago. And http://llvm.org/apt/ which is linked from their homepage returns 404.
The topic in the #llvm channel on IRC mentions:
APT repo temporary switched off. Check ML for the latest updates.
The ML announcement:
TL;DR: APT repo switched off due to excessive load / traffic
Recently we realized that APT repo generates almost 95% of I/O on
llvm.org and more than 40% of network bandwidth alone. During last 2
weeks the main services on llvm.org (svn, git, bugzilla) had serious
problems with overall connectivity.
We decided to temporary switch APT repo off to see if this would help.
Stay tuned for updates.
Temp solution
Since the llvm server still down I'm using the clang provided in the Ubuntu package.
addons:
apt:
sources:
- ubuntu-toolchain-r-test
#- llvm-toolchain-precise-3.7
packages:
- libgnome-keyring-dev
#- clang-3.7
- clang
Full example: https://github.com/sqlectron/sqlectron-gui/blob/master/.travis.yml#L35
The only problem is that installs the version 3.4 or 3.5. Which looks be much slower than the latest one available on llvm package.
The llvm server is still down. However, a very good idea from the people behind rust (https://github.com/rust-lang/rust) is to solve this issue by using Docker.
See the .travis.yml file here:
https://github.com/rust-lang/rust/commit/b1651fb4d2c0349ccca108b8d24210d688507936
You can find the travis build here:
https://travis-ci.org/rust-lang/rust/builds/134924068
I incorporated Docker into my builds with excellent results, but it took me a couple of days to do so. You can find my approach here: https://github.com/fuzzylite/fuzzylite/tree/master in files /Dockerfile and /.travis.yml
and the results here: https://travis-ci.org/fuzzylite/fuzzylite/builds/137058927
here is an example how to currently solve this and use clang 3.7.
sudo: required
dist: trusty
env:
global:
- LLVM_VERSION=3.7.0
- LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz
before_install:
- wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH
- mkdir $HOME/clang+llvm
- tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang+llvm --strip-components 1
- export PATH=$HOME/clang+llvm/bin:$PATH
I'm doing the same for clang 3.5/3.6/3.7/3.8 and it works.
I call clang++ and not clang++-3.7 or whatever - it is prepended to the PATH.

Salt virtualenv.managed using setup.py

I have my python package requirements in setup.py and I simply do pip install . from a directory where setup.py exists. I don't have a requirements file and I don't want to have one. How do I tell salt to use setup.py instead of requirements.txt?
Installing pip package to virtualenv and running setup.py should be different requirement.
I assume setup.py triggering is only mean for self-serving modules, external package should be put under saltstack virtualenv setup, so you can see if the required external package failed to install. But it also depends on your own taste.
To run setup.py inside your virtualenv, you must create a script that call the virutalenv, then run setup.py , e.g. vi run-setup.sh
#!/bin/bash
source $HOME/.virtualenv/xyz/bin/activate
cd $HOME/xyz_app
python setup.py
then use the cmd.run in state file to run it
run setup.py for my xyz app :
cmd_run:
- name: bash <xyz_app folder name>/run-setup.sh
- user: <username>
- group: <groupname>
UPDATE :
Since you want to load particular python package to your virtualenv, you can do it straight away during setup. Then only use cmd.run to load batch that launch setup.py (to make your custom app works)into the virtualenv.
create-my-apps-virtualenv:
virtualenv.managed:
- name: /home/myapphome/.virtualenv/myapp
- user: myappusername
- no_chown: False
# install this pacakge to my virtualenv, package must be case sensitive according.
- pip_pkgs: json, MySQL-python,SQLAlchemy

Resources